Chapter 2. Building Interactive Apps: Apps That Do Something
Most apps need to respond to the user in some way.
And in this chapter, youâll see how you can make your apps more interactive. Youâll discover how to add an OnClickListener to your activity code so that your app can listen to what the userâs doing, and make an appropriate response. Youâll find out more about how to design layouts, and youâll learn how each UI component you add to your layout is derived from a common View ancestor. Along the way, youâll discover why String resources are so important for flexible, well-designed apps.
Letâs build a Beer Adviser app
When you create an Android app, youâre usually going to want it to do something.
In this chapter, weâre going to show you how to create an app that the user can interact with. Weâll create a Beer Adviser app where users can select the color of beer they enjoy most, click a button, and get back a list of tasty beers to try out.
Hereâs how the app will be structured:
The layout activity_main.xml specifies what the app will look like.
It includes three UI components:
A drop-down list of values called a spinner, which allows the user to choose which color of beer they want
A button that, when clicked, will return a selection of beers ...
Get Head First Android Development, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.