Más contenido relacionado
Android Development 2: Notepad Application
- 1. Android Basic Course
© 2012 University of Science – HCM City.
M.Sc. Bui Tan Loc
btloc@fit.hcmus.edu.vn
Department of Software Engineering,
Faculty of Information Technology,
University of Science – Ho Chi Minh City, Viet Nam
Lab 2: Notepad application
- 2. Android Basic Course
© 2012 University of Science – HCM City.
Pre-requirements
• Module 4: User Interfaces - Activity
- 3. Android Basic Course
© 2012 University of Science – HCM City.
Notepad Exercise 1
• Do the tutorial for exercise 1:
• http://developer.android.com/resources/tutorials/notepad/notepa
d-ex1.html
• After completing this tutorial, you will have practiced
about:
• Creating xml-based layout files such as notepad_list.xml,
notes_row.xml.
• Modifying string.xml resource.
• Creating options menu by using code.
• Handling options menu selections.
• Creating and loading resources for a ListView.
• Filling data into a ListView.
- 4. Android Basic Course
© 2012 University of Science – HCM City.
Notepad Exercise 2
• Do the tutorial for exercise 2:
• http://developer.android.com/resources/tutorials/notepad/notepa
d-ex2.html
• After completing this tutorial, you will have practiced
about:
• Creating context menu by using code.
• Handling context menu selections.
• Using Intent object to start an activity for a result.
• Starting an activity for passing values by putting values into Intent
object.
• Using layout_weight attribute.
• Loading views from xml-based layout file by using findViewById()
method.
• Using Intent object to read passed values.
• Using event listeners.
• Declaring a new activity in AndroidManifest.xml file.
- 5. Android Basic Course
© 2012 University of Science – HCM City.
Notepad Exercise 3
• Do the tutorial for exercise 3:
• http://developer.android.com/resources/tutorials/notepad/notepa
d-ex3.html
• After completing this tutorial, you will have practiced
about:
• Managing the Activity lifecycle with onCreate(), onPause(),
onResume(), and onSaveInstancesState() method.
- 6. Android Basic Course
© 2012 University of Science – HCM City.
Notepad Extra Credit
• Do the tutorial:
• http://developer.android.com/resources/tutorials/notepad/notepa
d-extra-credit.html
• After completing this tutorial, you will have:
• Practiced about using DMMS tools to emulate voice calls or SMS messages.
• Learned about the time which onCreate(), onPause(), onResume(), or
onSaveInstancesState() method is called.
- 7. Android Basic Course
© 2012 University of Science – HCM City.
More requirements
• Try creating menus by loading from xml resources (not
using code to create menu items).
• Try adding icons (images) for menu items.
• Try using event listener technique for menu item
selections (not using onOptionsItemSelected or
onContextItemSelected function)
- 8. Android Basic Course
© 2012 University of Science – HCM City.
Questions or Discussions
• Why do we not use onRestoreInstancesState() to
manage the Activity lifecycle in this Notepad
application?
• What is the difference between using event handlers
(onOptionsItemSelected, onContextItemSelected) and
using event listeners (setOnMenuItemClickListener)?