android app development 20150507
TRANSCRIPT
Android App Development 4
7 May, 2015
Building a Simple User Interface Add a Button Weight Attribute
Exercise1
Last Workshop
2/9 3/9 4/9
Activity An application component that provides a
screen with which users can interact
Starting Another Activity
click
In java directory, select the package com.mycompany.myfirstapp, right-click
Select New > Activity > Blank Activity
Create the Second Activity
Activity Name: DisplayMessageActivity Layout Name: acticity_display_message Title: My Message Hierarchical Parent:
com.mycompany.myfirstapp.MyActivity Package name:com.mycompany.myfirstapp
Create the Second Activity
Edit res/layout/activity_display_message.xml
Edit res/values/strings.xml
Create the Second Activity
Add “Go Next” ButtonCreate the Second Activity
LinearLayout
(horizontal)
ButtonText Field
Button
LinearLayout
(vertical)
LinearLayout
(horizontal)
ButtonText Field
Button
LinearLayout
(vertical)
Width = match_parentHeight = match_paremt
Width = match_parentHeight = match_parent
wrap_content
Add “Go Next” Buttonactivity_my.xml
LinearLayout
(horizontal)
ButtonText Field
Button
LinearLayout
(vertical)
Create the Second Activity
Edit res/layout/activity_my.xml Add onClick attribute
Respond to “Go Next” Button
Edit MyActivity.java Add the goNextActivity() method
Respond to the “Go Next” Button
1. Build an Intent Intent
An object that provides runtime binding between separate components (such as two activities)
2. Add a startActivity Method
goNextActivity() Method
①②
At the top of “MyActivity.java”, import the Intent class
Respond to “Go Next” Button
When you start a new Activity,you need to build an Intent first.
click
click
click
Add a New Button LinearLayout (vertical)
Starting Another Activity Create the Second Activity goNextActivity() Method
Build an Intent Add a startActivity Method
Next Workshop Adding Multimedia to your App
Wrap Up for Today
fin.