SlideShare une entreprise Scribd logo
1  sur  25
2013.05.022013.05.02
Android apps development IAndroid apps development I
- How to build your first app.- How to build your first app.
Introduction ofIntroduction of
2013.05.022013.05.02
ContentContent
 UI & Environment Intro.UI & Environment Intro.
 Say Hello World!Say Hello World!
 Layout Intro.Layout Intro.
 Add the behaviorAdd the behavior

2013.05.022013.05.02
 srcsrc
•
javajava 原始碼原始碼
 res (resource)res (resource)
•
iconsicons
•
layoutlayout
•
string...etc.string...etc.
 libslibs 靜態函式庫靜態函式庫
Package ExplorerPackage Explorer
2013.05.022013.05.02
LayoutLayout
Let's see RAW content (.xml)Let's see RAW content (.xml)
2013.05.022013.05.02
Layout – res / layout / main.xmlLayout – res / layout / main.xml
2013.05.022013.05.02
Layout StructureLayout Structure
 ViewGroupViewGroup
●
A layout or container such asA layout or container such as RelativeLayoutRelativeLayout
oror LinearLayoutLinearLayout
 ViewView
●
A child of ViewGroup such asA child of ViewGroup such as buttonbutton oror texttext
fieldfield
2013.05.022013.05.02
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
Layout – View (TextView)Layout – View (TextView)
@ 代表一個 pointer ,指向真正的字串內容
2013.05.022013.05.02
Layout – res / values / strings.xmlLayout – res / values / strings.xml
for i18n purpose
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Hello World</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
</resources>
2013.05.022013.05.02
Add behaviorAdd behavior
Scenerio:
畫面上有一顆按鈕,當按下按鈕
後,在其下方出現預藏的文字。
2013.05.022013.05.02
Add behavior (cont.)Add behavior (cont.)
1. Add a button
2. Hide the text
3. Make the button show text
2013.05.022013.05.02
Add behavior (cont.)Add behavior (cont.)
1. Add a button1. Add a button
1-1. 利用滑鼠 曳新增一按鈕拖
1-2. 設定按鈕上的提示文字
2013.05.022013.05.02
Add behavior (cont.)Add behavior (cont.)
2. Hide the text2. Hide the text
android:visibility="invisible"
 Just add the attribution to TextViewJust add the attribution to TextView
But how do I know what
attribution I can use?
2013.05.022013.05.02
Add behavior (cont.)Add behavior (cont.)
2. Hide the text2. Hide the text
 Go toGo to android developer siteandroid developer site
•
ReferenceReference
•
android.wigetandroid.wiget
•
TextViewTextView
•
Inherited XML AttributesInherited XML Attributes
•
Attribute NameAttribute Name
•
android:visibilityandroid:visibility
2013.05.022013.05.02
Add behavior (cont.)Add behavior (cont.)
Invisible
你看不到我,你看不到我
但是 ... 仍然佔據空間
2013.05.022013.05.02
Add behavior (cont.)Add behavior (cont.)
3. Make the button show text3. Make the button show text
3-1. add the attribution to button3-1. add the attribution to button
android:onClick="android:onClick="showTextshowText""
3-2. write the code of3-2. write the code of showTextshowText
methodmethod
2013.05.022013.05.02
Add behavior (cont.)Add behavior (cont.)
3. Make the button show text3. Make the button show text
3-1. add the attribution to button3-1. add the attribution to button
android:onClick="android:onClick="showTextshowText""
3-2. write the code of3-2. write the code of showTextshowText
methodmethod
2013.05.022013.05.02
Add behavior (cont.)Add behavior (cont.)
3. Make the button show text3. Make the button show text
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btn_click_text"
android:onClick="showText" />
main.xml
2013.05.022013.05.02
Add behavior (cont.)Add behavior (cont.)
3. Make the button show text3. Make the button show text
Main.java
public void showText (View view) {
// - 宣告元件
// - 操作元件
}
2013.05.022013.05.02
Add behavior (cont.)Add behavior (cont.)
3. Make the button show text3. Make the button show text
Bridge to XML & JAVA
.xml .java
R.* 資源檔
findViewById
2013.05.022013.05.02
Add behavior (cont.)Add behavior (cont.)
3. Make the button show text3. Make the button show text
findViewById example
// 在 Main.java 中宣告 UI 中的 button1
Button button = (Button) findViewById (R.id.button1);
// 在 Main.java 中宣告 UI 中的 TextView
TextView textView = (TextView) findViewById (R.id.tv1);
Main.java
2013.05.022013.05.02
Add behavior (cont.)Add behavior (cont.)
3. Make the button show text3. Make the button show text
R.id.tv1 ?什麼東西?好像沒看過?
TextView 預設沒給定操作 id ,加上它吧!
main.xml
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button1"
android:id="@+id/tv1"
android:text="@string/hello_world"
android:visibility="invisible" />
2013.05.022013.05.02
Add behavior (cont.)Add behavior (cont.)
3. Make the button show text3. Make the button show text
Main.java
public void showText(View view) {
Button button = (Button) findViewById(R.id.button1);
TextView tv1 = (TextView) findViewById(R.id.tv1);
tv1.setVisibility(View.VISIBLE);
}
2013.05.022013.05.02
Again, how do I know
what method I can use?
Add behavior (cont.)Add behavior (cont.)
2013.05.022013.05.02
 Go toGo to android developer siteandroid developer site
•
ReferenceReference
•
android.wigetandroid.wiget
•
TextViewTextView
•
Inherited XML AttributesInherited XML Attributes
•
Related MethodRelated Method
•
setVisibility(int)setVisibility(int)
Add behavior (cont.)Add behavior (cont.)
2013.05.022013.05.02
Thanks!

Contenu connexe

En vedette

Reload hair medica slideshare 6.3 (2)
Reload hair medica slideshare 6.3 (2)Reload hair medica slideshare 6.3 (2)
Reload hair medica slideshare 6.3 (2)
Laurie Reda
 
Top 10 liaison nurse interview questions and answers
Top 10 liaison nurse interview questions and answersTop 10 liaison nurse interview questions and answers
Top 10 liaison nurse interview questions and answers
tonychoper8006
 

En vedette (17)

Votação do Deputado Estadual em Ijuí
Votação do Deputado Estadual em IjuíVotação do Deputado Estadual em Ijuí
Votação do Deputado Estadual em Ijuí
 
Internet
InternetInternet
Internet
 
Reload hair medica slideshare 6.3 (2)
Reload hair medica slideshare 6.3 (2)Reload hair medica slideshare 6.3 (2)
Reload hair medica slideshare 6.3 (2)
 
Futbol
FutbolFutbol
Futbol
 
Proyecto integrado igss pedia modificado
Proyecto integrado igss pedia modificadoProyecto integrado igss pedia modificado
Proyecto integrado igss pedia modificado
 
Tecnicas visuales graficas
Tecnicas visuales graficasTecnicas visuales graficas
Tecnicas visuales graficas
 
Bab4masakan 091220042254-phpapp02
Bab4masakan 091220042254-phpapp02Bab4masakan 091220042254-phpapp02
Bab4masakan 091220042254-phpapp02
 
Presentación Carlos Carvajal- eCommerce Day Santiago 2015
Presentación Carlos Carvajal- eCommerce Day Santiago 2015 Presentación Carlos Carvajal- eCommerce Day Santiago 2015
Presentación Carlos Carvajal- eCommerce Day Santiago 2015
 
Dale dentido y dirección a tus propósitos. 1er aniversario de la Fundacion J...
Dale dentido y dirección a tus propósitos.  1er aniversario de la Fundacion J...Dale dentido y dirección a tus propósitos.  1er aniversario de la Fundacion J...
Dale dentido y dirección a tus propósitos. 1er aniversario de la Fundacion J...
 
Sara garcia
Sara garciaSara garcia
Sara garcia
 
Arte
ArteArte
Arte
 
GNL Cadena de valor
GNL Cadena de valorGNL Cadena de valor
GNL Cadena de valor
 
Human Centric Retail - Fujitsu
Human Centric Retail - FujitsuHuman Centric Retail - Fujitsu
Human Centric Retail - Fujitsu
 
Normas Ortográficas Básicas
Normas Ortográficas BásicasNormas Ortográficas Básicas
Normas Ortográficas Básicas
 
Top 10 liaison nurse interview questions and answers
Top 10 liaison nurse interview questions and answersTop 10 liaison nurse interview questions and answers
Top 10 liaison nurse interview questions and answers
 
Presentacio
PresentacioPresentacio
Presentacio
 
Fundamentos higiene y seguridad industrial
Fundamentos higiene y seguridad industrialFundamentos higiene y seguridad industrial
Fundamentos higiene y seguridad industrial
 

Similaire à 2013.05.02 android-l1

Android howto hellowidget
Android howto hellowidgetAndroid howto hellowidget
Android howto hellowidget
Hiron Das
 
行動App開發管理實務 unit2
行動App開發管理實務 unit2行動App開發管理實務 unit2
行動App開發管理實務 unit2
Xavier Yin
 

Similaire à 2013.05.02 android-l1 (20)

Android Custom views
Android Custom views   Android Custom views
Android Custom views
 
Android how to hellowidget
Android how to hellowidgetAndroid how to hellowidget
Android how to hellowidget
 
Android howto hellowidget
Android howto hellowidgetAndroid howto hellowidget
Android howto hellowidget
 
Ap quiz app
Ap quiz appAp quiz app
Ap quiz app
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
 
Django web framework
Django web frameworkDjango web framework
Django web framework
 
04 objective-c session 4
04  objective-c session 404  objective-c session 4
04 objective-c session 4
 
行動App開發管理實務 unit2
行動App開發管理實務 unit2行動App開發管理實務 unit2
行動App開發管理實務 unit2
 
Different types of sticker apps
Different types of sticker appsDifferent types of sticker apps
Different types of sticker apps
 
OroCommerce Storefront Design. Non-standard Layout Customisation.
OroCommerce Storefront Design. Non-standard Layout Customisation.OroCommerce Storefront Design. Non-standard Layout Customisation.
OroCommerce Storefront Design. Non-standard Layout Customisation.
 
Angularjs 2
Angularjs 2 Angularjs 2
Angularjs 2
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
 
Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_program
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
Testing android apps with espresso
Testing android apps with espressoTesting android apps with espresso
Testing android apps with espresso
 
Yeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsYeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web apps
 
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
 
Bootstrap with liferay
Bootstrap with liferayBootstrap with liferay
Bootstrap with liferay
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

2013.05.02 android-l1