In this chapter, you created the Twitter Searches app. First you designed the GUI. We introduced the ListView
component for displaying a scrollable list of items and used it to display the arbitrarily large list of saved searches. Each search was associated with an item in the ListView
that the user could touch to pass the search to the device’s web browser. You also learned how to create String
resources for use in your Java code.
We stored the search tag–query pairs in a SharedPreferences
file associated with the app and showed how to programmatically hide the soft keyboard. We also used a SharedPreferences.Editor
object to store values in, modify values in and remove values from a SharedPreferences
file. In response to the user touching a search tag, we loaded a Uri
into the device’s web browser by creating a new Intent
and passing it to Context
’s startActivity
method. You also used an Intent
to display an intent chooser allowing the user to select an Activity for sharing a search.
You used AlertDialog.Builder
objects to configure and create AlertDialog
s for displaying messages to the user. Finally, we discussed the AndroidManifest.xml
file and showed you how to configure the app so that the soft keyboard is not displayed when the app is launched.
In Chapter 5, you’ll build the Flag Quiz app in which the user is shown a graphic of a country’s flag and must guess the country from 3, 6 or 9 choices. You’ll use a menu and checkboxes to customize the quiz, limiting the flags and countries chosen to specific regions of the world.