SlideShare a Scribd company logo
Exercises:
                      Android Programming Basics
1.    Make an app that contains two Buttons (with labels “Push Me” and “Click Me”) and a
      TextView (with text “This is a Test”). Use the XML-based approach, and you can hard-
      code the label of the buttons and the text of the TextView inside main.xml (i.e., you do not
      need to use strings.xml at all yet). Use the android:text attribute in both cases, but it is eas-
      iest to use the visual editor first, then edit main.xml later. Nothing needs to happen when
      you press the buttons.

2.    Test your app on the emulator.

3.    If you have an Android phone or tablet, test your app on it.

4.    Update your app so that the Button labels and TextView text are taken from strings.xml.

5.    Give your buttons some behavior. Here are some options for the button behaviors:
      • Make them pop up Toasts (copy the code from the app from the lecture, which you can
        download from the Web site)
      • Have them change the color of the Button that was clicked. To change the color of the
        Button, call setBackgroundColor on the View that is passed to the event handler. Choose
        at random among Color.RED, Color.BLUE, Color.YELLOW, etc..
      • Have them change the text of the Button to “I was clicked n times”. Use two instance
        variables for the counts.

        Use either the pure-XML way or the hybrid way of assigning the event handler.

        Test on the emulator and, if you have one, a real phone or tablet.

6.    Make a new app that is similar to the old one, but this time, when you press a button, it
      should change the color of the TextView instead of the color of the button that was
      pressed. You can assign the event handler either in XML or in Java, but you’ll need to at
      least partially use the hybrid approach because you need an explicit Java reference to the
      TextView that was defined in the XML file.




 Customized Java EE training: Android, JSF 2.0, JSP, servlets, Java 6, Ajax, jQuery, Spring, Hibernate, REST, GWT, etc. http://www.coreservlets.com

More Related Content

Viewers also liked

Production schedule w.b.21.01.13
Production schedule  w.b.21.01.13Production schedule  w.b.21.01.13
Production schedule w.b.21.01.13
Steampunk_Productions
 
Bits y atomos
Bits y atomosBits y atomos
Bits y atomos
1012333367
 
Convocatoria beca hce
Convocatoria beca hceConvocatoria beca hce
Convocatoria beca hce
Moisés Miranda
 
Alp sp-shoulder
Alp sp-shoulderAlp sp-shoulder
Alp sp-shoulder
AV ProfShop
 

Viewers also liked (7)

Presidents List
Presidents ListPresidents List
Presidents List
 
Production schedule w.b.21.01.13
Production schedule  w.b.21.01.13Production schedule  w.b.21.01.13
Production schedule w.b.21.01.13
 
Lista de coches
Lista de cochesLista de coches
Lista de coches
 
K Gilby Certs
K Gilby CertsK Gilby Certs
K Gilby Certs
 
Bits y atomos
Bits y atomosBits y atomos
Bits y atomos
 
Convocatoria beca hce
Convocatoria beca hceConvocatoria beca hce
Convocatoria beca hce
 
Alp sp-shoulder
Alp sp-shoulderAlp sp-shoulder
Alp sp-shoulder
 

Similar to asd

App Inventor : Getting Started Guide
App Inventor : Getting Started GuideApp Inventor : Getting Started Guide
App Inventor : Getting Started Guide
Vasilis Drimtzias
 
Tat learning applications en
Tat learning applications enTat learning applications en
Tat learning applications en
Toni Setyawan
 
Ap quiz app
Ap quiz appAp quiz app
Ap quiz app
angelicaurio
 
Lab3-Android
Lab3-AndroidLab3-Android
Lab3-Android
Lilia Sfaxi
 
Immutable Data and TypeScript in an Ember.js Application
Immutable Data and TypeScript in an Ember.js ApplicationImmutable Data and TypeScript in an Ember.js Application
Immutable Data and TypeScript in an Ember.js Application
Bill Heaton
 
Android interface elements and controls-chapter8
Android interface elements and controls-chapter8Android interface elements and controls-chapter8
Android interface elements and controls-chapter8
Dr. Ramkumar Lakshminarayanan
 
Android tutorials7 calculator
Android tutorials7 calculatorAndroid tutorials7 calculator
Android tutorials7 calculator
Vlad Kolesnyk
 
Android Application Development - Level 2
Android Application Development - Level 2Android Application Development - Level 2
Android Application Development - Level 2
Isham Rashik
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
Ahsanul Karim
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]
Ahsanul Karim
 
I need some help answering these three questions listed below.1. A.pdf
I need some help answering these three questions listed below.1. A.pdfI need some help answering these three questions listed below.1. A.pdf
I need some help answering these three questions listed below.1. A.pdf
arjunstores123
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
Denis Minja
 
Twitter trends
Twitter trendsTwitter trends
1.2 statements, properties, and operations
1.2   statements, properties, and operations1.2   statements, properties, and operations
1.2 statements, properties, and operations
allenbailey
 
Sudplan_sms_issue_reporting_template
Sudplan_sms_issue_reporting_templateSudplan_sms_issue_reporting_template
Sudplan_sms_issue_reporting_template
martinscholl
 
MD-IV-CH-ppt.ppt
MD-IV-CH-ppt.pptMD-IV-CH-ppt.ppt
MD-IV-CH-ppt.ppt
bharatt7
 
Building a simple user interface lesson2
Building a simple user interface lesson2Building a simple user interface lesson2
Building a simple user interface lesson2
Kalluri Vinay Reddy
 
GUI programming
GUI programmingGUI programming
GUI programming
Vineeta Garg
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
Hussain Behestee
 
70 357 practice test
70 357 practice test70 357 practice test
70 357 practice test
shirlybaker1
 

Similar to asd (20)

App Inventor : Getting Started Guide
App Inventor : Getting Started GuideApp Inventor : Getting Started Guide
App Inventor : Getting Started Guide
 
Tat learning applications en
Tat learning applications enTat learning applications en
Tat learning applications en
 
Ap quiz app
Ap quiz appAp quiz app
Ap quiz app
 
Lab3-Android
Lab3-AndroidLab3-Android
Lab3-Android
 
Immutable Data and TypeScript in an Ember.js Application
Immutable Data and TypeScript in an Ember.js ApplicationImmutable Data and TypeScript in an Ember.js Application
Immutable Data and TypeScript in an Ember.js Application
 
Android interface elements and controls-chapter8
Android interface elements and controls-chapter8Android interface elements and controls-chapter8
Android interface elements and controls-chapter8
 
Android tutorials7 calculator
Android tutorials7 calculatorAndroid tutorials7 calculator
Android tutorials7 calculator
 
Android Application Development - Level 2
Android Application Development - Level 2Android Application Development - Level 2
Android Application Development - Level 2
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]
 
I need some help answering these three questions listed below.1. A.pdf
I need some help answering these three questions listed below.1. A.pdfI need some help answering these three questions listed below.1. A.pdf
I need some help answering these three questions listed below.1. A.pdf
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
 
Twitter trends
Twitter trendsTwitter trends
Twitter trends
 
1.2 statements, properties, and operations
1.2   statements, properties, and operations1.2   statements, properties, and operations
1.2 statements, properties, and operations
 
Sudplan_sms_issue_reporting_template
Sudplan_sms_issue_reporting_templateSudplan_sms_issue_reporting_template
Sudplan_sms_issue_reporting_template
 
MD-IV-CH-ppt.ppt
MD-IV-CH-ppt.pptMD-IV-CH-ppt.ppt
MD-IV-CH-ppt.ppt
 
Building a simple user interface lesson2
Building a simple user interface lesson2Building a simple user interface lesson2
Building a simple user interface lesson2
 
GUI programming
GUI programmingGUI programming
GUI programming
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
 
70 357 practice test
70 357 practice test70 357 practice test
70 357 practice test
 

More from gilvanphp

Metal Gear Solid
Metal Gear SolidMetal Gear Solid
Metal Gear Solid
gilvanphp
 
Gilvanjjj
GilvanjjjGilvanjjj
Gilvanjjj
gilvanphp
 
Gilvanjjj
GilvanjjjGilvanjjj
Gilvanjjj
gilvanphp
 
Gilvan
GilvanGilvan
Gilvan
gilvanphp
 
1564
15641564
1564
gilvanphp
 
vuj
vujvuj
acaf
acafacaf
acaf
gilvanphp
 
acaf
acafacaf
acaf
gilvanphp
 
acaf
acafacaf
acaf
gilvanphp
 
Gilvan Júnior Teste
Gilvan Júnior TesteGilvan Júnior Teste
Gilvan Júnior Teste
gilvanphp
 
Gilvan Júnior Teste
Gilvan Júnior TesteGilvan Júnior Teste
Gilvan Júnior Teste
gilvanphp
 
teste 1
teste 1teste 1
teste 1
gilvanphp
 
teste 1
teste 1teste 1
teste 1
gilvanphp
 
teste 1
teste 1teste 1
teste 1
gilvanphp
 
teste 1
teste 1teste 1
teste 1
gilvanphp
 
teste 1
teste 1teste 1
teste 1
gilvanphp
 
teste 1
teste 1teste 1
teste 1
gilvanphp
 
teste 1
teste 1teste 1
teste 1
gilvanphp
 
teste 1
teste 1teste 1
teste 1
gilvanphp
 
teste 1
teste 1teste 1
teste 1
gilvanphp
 

More from gilvanphp (20)

Metal Gear Solid
Metal Gear SolidMetal Gear Solid
Metal Gear Solid
 
Gilvanjjj
GilvanjjjGilvanjjj
Gilvanjjj
 
Gilvanjjj
GilvanjjjGilvanjjj
Gilvanjjj
 
Gilvan
GilvanGilvan
Gilvan
 
1564
15641564
1564
 
vuj
vujvuj
vuj
 
acaf
acafacaf
acaf
 
acaf
acafacaf
acaf
 
acaf
acafacaf
acaf
 
Gilvan Júnior Teste
Gilvan Júnior TesteGilvan Júnior Teste
Gilvan Júnior Teste
 
Gilvan Júnior Teste
Gilvan Júnior TesteGilvan Júnior Teste
Gilvan Júnior Teste
 
teste 1
teste 1teste 1
teste 1
 
teste 1
teste 1teste 1
teste 1
 
teste 1
teste 1teste 1
teste 1
 
teste 1
teste 1teste 1
teste 1
 
teste 1
teste 1teste 1
teste 1
 
teste 1
teste 1teste 1
teste 1
 
teste 1
teste 1teste 1
teste 1
 
teste 1
teste 1teste 1
teste 1
 
teste 1
teste 1teste 1
teste 1
 

asd

  • 1. Exercises: Android Programming Basics 1. Make an app that contains two Buttons (with labels “Push Me” and “Click Me”) and a TextView (with text “This is a Test”). Use the XML-based approach, and you can hard- code the label of the buttons and the text of the TextView inside main.xml (i.e., you do not need to use strings.xml at all yet). Use the android:text attribute in both cases, but it is eas- iest to use the visual editor first, then edit main.xml later. Nothing needs to happen when you press the buttons. 2. Test your app on the emulator. 3. If you have an Android phone or tablet, test your app on it. 4. Update your app so that the Button labels and TextView text are taken from strings.xml. 5. Give your buttons some behavior. Here are some options for the button behaviors: • Make them pop up Toasts (copy the code from the app from the lecture, which you can download from the Web site) • Have them change the color of the Button that was clicked. To change the color of the Button, call setBackgroundColor on the View that is passed to the event handler. Choose at random among Color.RED, Color.BLUE, Color.YELLOW, etc.. • Have them change the text of the Button to “I was clicked n times”. Use two instance variables for the counts. Use either the pure-XML way or the hybrid way of assigning the event handler. Test on the emulator and, if you have one, a real phone or tablet. 6. Make a new app that is similar to the old one, but this time, when you press a button, it should change the color of the TextView instead of the color of the button that was pressed. You can assign the event handler either in XML or in Java, but you’ll need to at least partially use the hybrid approach because you need an explicit Java reference to the TextView that was defined in the XML file. Customized Java EE training: Android, JSF 2.0, JSP, servlets, Java 6, Ajax, jQuery, Spring, Hibernate, REST, GWT, etc. http://www.coreservlets.com