android app development 20150507

18
Android App Development 4 7 May, 2015

Upload: hideo-kadowaki

Post on 14-Aug-2015

157 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Android App Development 20150507

Android App Development 4

7 May, 2015

Page 2: Android App Development 20150507

Building a Simple User Interface Add a Button Weight Attribute

Exercise1

Last Workshop

2/9 3/9 4/9

Page 3: Android App Development 20150507

Activity An application component that provides a

screen with which users can interact

Starting Another Activity

Page 4: Android App Development 20150507

click

Page 5: Android App Development 20150507

In java directory, select the package com.mycompany.myfirstapp, right-click

Select New > Activity > Blank Activity

Create the Second Activity

Page 6: Android App Development 20150507

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

Page 7: Android App Development 20150507

Edit res/layout/activity_display_message.xml

Edit res/values/strings.xml

Create the Second Activity

Page 8: Android App Development 20150507

Add “Go Next” ButtonCreate the Second Activity

Page 9: Android App Development 20150507

LinearLayout

(horizontal)

ButtonText Field

Button

LinearLayout

(vertical)

Page 10: Android App Development 20150507

LinearLayout

(horizontal)

ButtonText Field

Button

LinearLayout

(vertical)

Width = match_parentHeight = match_paremt

Width = match_parentHeight = match_parent

wrap_content

Page 11: Android App Development 20150507
Page 12: Android App Development 20150507

Add “Go Next” Buttonactivity_my.xml

LinearLayout

(horizontal)

ButtonText Field

Button

LinearLayout

(vertical)

Create the Second Activity

Page 13: Android App Development 20150507

Edit res/layout/activity_my.xml Add onClick attribute

Respond to “Go Next” Button

Page 14: Android App Development 20150507

Edit MyActivity.java Add the goNextActivity() method

Respond to the “Go Next” Button

Page 15: Android App Development 20150507

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.

Page 16: Android App Development 20150507

click

click

click

Page 17: Android App Development 20150507

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

Page 18: Android App Development 20150507

fin.