Chapter 3. User interfaces

This chapter covers

  • Understanding activities and views
  • Exploring the Activity lifecycle
  • Working with resources
  • Exploring the AndroidManifest.xml file

With our introductory tour of the main components of the Android platform and development environment complete, it’s time to look more closely at the fundamental Android concepts surrounding activities, views, and resources. Activities are essential because, as you learned in chapter 1, they make up the screens of your application and play a key role in the Android application lifecycle. Rather than allowing any one application to wrest control of the device away from the user and from other applications, Android introduces a well-defined lifecycle to manage processes as needed. It’s essential to understand not only how to start and stop an Android Activity, but also how to suspend and resume one. Activities themselves are made up of subcomponents called views.

Views are what your users see and interact with. Views handle layout, provide text elements for labels and feedback, provide buttons and forms for user input, and draw graphics to the device screen. Views are also used to register interface event listeners, such as those for touch-screen controls. A hierarchical collection of views is used to compose an Activity. You’re the conductor, an Activity is your symphony, and View objects are your musicians.

3.1. Creating the Activity

3.2. Working with views

3.3. Using resources

3.4. Exploring the AndroidManifest file

3.5. Summary

sitemap