Top Banner
行行 APP 行行行行行行 Button, TextView and EditText 行行行 Xavier Yin
34

行動App開發管理實務 unit2

Jul 30, 2015

Download

Education

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 行動App開發管理實務 unit2

行動 APP 開發管理實務Button, TextView and EditText

尹君耀 Xavier Yin

Page 2: 行動App開發管理實務 unit2

Outline

Review

Prior Knowledge

Button

Events

TextView

Practice

Page 3: 行動App開發管理實務 unit2

Review

Install Android Studio– Java, Android SDK and IDE

How to development your app?– Create an empty project– Arrange your resources– Bind your resources into an Activity file(java class)– Set Manifest file– Launch an emulator or real device

Page 4: 行動App開發管理實務 unit2

Basic Components

Activity

Service

BroadcastReceiver

ContentProvider

Page 5: 行動App開發管理實務 unit2

UI Components

View class– This class represents the basic

building block for user interface components.

ViewGroup class– The ViewGroup subclass is the

base class for layouts, which are invisible containers that hold other Views (or other ViewGroups) and define their layout properties.

Page 6: 行動App開發管理實務 unit2

UI Components

View class– This class represents the basic

building block for user interface components.

ViewGroup class– The ViewGroup subclass is the

base class for layouts, which are invisible containers that hold other Views (or other ViewGroups) and define their layout properties.

Page 7: 行動App開發管理實務 unit2

UI Components

View class– This class represents the basic

building block for user interface components.

ViewGroup class– The ViewGroup subclass is the

base class for layouts, which are invisible containers that hold other Views (or other ViewGroups) and define their layout properties.

Page 8: 行動App開發管理實務 unit2

Button

Button – Represents a push-button widget. Push-buttons can be pressed,

or clicked, by the user to perform an action.

– A button consists of text or an icon (or both text and an icon) that communicates what action occurs when the user touches it.

Page 9: 行動App開發管理實務 unit2

TextView and EditText

TextView– Displays text to the user and

optionally allows them to edit it.

EditText– EditText is a thin veneer

over TextView that configures itself to be editable.

Page 10: 行動App開發管理實務 unit2

TextView and EditText

TextView– Displays text to the user and

optionally allows them to edit it.

EditText– EditText is a thin veneer

over TextView that configures itself to be editable.

Page 11: 行動App開發管理實務 unit2

TextView and EditText

TextView– Displays text to the user and

optionally allows them to edit it.

EditText– EditText is a thin veneer

over TextView that configures itself to be editable.

Page 12: 行動App開發管理實務 unit2

Event Listeners

Event Listeners– An event listener is an interface in the View class that contains a

single callback method. These methods will be called by the Android framework when the View to which the listener has been registered is triggered by user interaction with the item in the UI.

– Included in the event listener interfaces are the following callback methods: onClick() onTouch() onLongClick() onFocusChange() onKey()

Page 13: 行動App開發管理實務 unit2

Practice

Requirements

ActivityA

Page 14: 行動App開發管理實務 unit2

Practice

Requirements

ActivityA ActivityB

Page 15: 行動App開發管理實務 unit2

Practice

Requirements

ActivityA ActivityB

Page 16: 行動App開發管理實務 unit2

Practice

Requirements

ActivityA

Page 17: 行動App開發管理實務 unit2

Practice

Create an empty project

Launch an emulator– Create a Virtual Device…

3.2”QVGA….. armeabi

Analyze your requirements (res)– Colors: #AEE32345– Dimens: 10dp– Strings: Android 原生按鈕 , 送出 , Activity A 的結果: %s 。 , 請在

EditText 輸入您需要的內容。 , 無法找到相對應的結果

Page 18: 行動App開發管理實務 unit2

Practice

Analyze your requirements– Layout: laout_activity_a.xml, laout_activity_b.xml

Bind the above files with your java files– ActivityA.java and ActivityB.java

Modify Manifest.xml– ActivityA is a Main program– ActivityB

Page 19: 行動App開發管理實務 unit2

Sample Code and Slides

Slides– https://www.slideshare.net/secret/JtRP83lClHIKi7

Sample Code– SimpleUnit2

https://github.com/xavier0507/TKUSampleCode_SimpleUnit2.git

– Advanced https://github.com/xavier0507/TKUSampleCode_Unit2.git

Page 20: 行動App開發管理實務 unit2

References

Android developers:– http://developer.android.com/design/index.html

Page 21: 行動App開發管理實務 unit2

Practice

Requirements

Page 22: 行動App開發管理實務 unit2

Practice

Requirements

Page 23: 行動App開發管理實務 unit2

Practice

Requirements

Clicked

Page 24: 行動App開發管理實務 unit2

Practice

Requirements

Page 25: 行動App開發管理實務 unit2

Practice

Requirements: activity_main.xml

10dp

Center

20dp20dp20dp20dp

1. Original Button:TextColor: #FF000000TextSize: MediumBackgroundColor: default

2. MyStyle Button:TextColor: #FF000000TextSize: MediumTextStyle: BoldBackgroundColor: default

3. Custom Button:TextColor: #FF000000Corners-radius = 10dpStroke-width = 3dp, color = #FF001113Gradient-type = linear, startColor = #FF449DEF,centerColor = #FF2F6699, endColor = #FF449DEF

4. Custom Clickable Button:TextColor: #FF000000

Normal state:Corners-radius = 5dpStroke-width = 1dp, color = #FF001113Solid-color = #FFEE3456

Pressed state:Corners-radius = 5dpStroke-width = 1dp, color = #FF001113Solid-color = #33EE3456

Page 26: 行動App開發管理實務 unit2

Practice

Requirements: activity_show_result.xml10dp

10dp

10dp

3. Custom Clickable Button:TextColor: #FF000000

Normal state:Corners-radius = 5dpStroke-width = 1dp, color = #FF001113Solid-color = #FFEE3456

Pressed state:Corners-radius = 5dpStroke-width = 1dp, color = #FF001113Solid-color = #33EE3456

1. TextView:TextColor: #FF000000TextSize: MediumBackgroundColor: default

2. EditText:TextColor: #FFFFFFFFTextSize: MediumBackgroundColor: #FF000000SingleLine: true

Page 27: 行動App開發管理實務 unit2

Practice

Create a new project– Empty project

Define resources that you need– Colors.xml

Page 28: 行動App開發管理實務 unit2

Practice

Define resources that you need– dimens.xml

Page 29: 行動App開發管理實務 unit2

Practice

Define resources that you need– strings.xml

Page 30: 行動App開發管理實務 unit2

Practice

Define resources that you need– styles.xml

Page 31: 行動App開發管理實務 unit2

Practice

Prepare Layout files– activity_main.xml

Page 32: 行動App開發管理實務 unit2

Practice

Prepare Layout files– activity_show_result.xml

Page 33: 行動App開發管理實務 unit2

Practice

Bind the above files with your java files– MainActivity

setContentView(R.layout.activity_main) Find components Set Click Listener and create an Intent

– ResultActivity getIntent() TextView sets text content

– Constant

Page 34: 行動App開發管理實務 unit2

Practice

Define App Manifest file– Intent-filter– Add ResultActivity

Launch your App in a device or make other components.