Objectives
In this chapter you’ll:
Use Fragment
s to make better use of available screen real estate in an Activity
’s GUI on phones and tablets.
Display an options menu on the action bar to enable users to configure the app’s preferences.
Use a PreferenceFragment
to automatically manage and persist an app’s user preferences.
Use an app’s assets
subfolders to organize image resources and manipulate them with an AssetManager
.
Define an animation and apply it to a View
.
Use a Handler
to schedule a future task to perform on the GUI thread.
Use Toast
s to display messages briefly to the user.
Launch a specific Activity
with an explicit Intent
.
Use various collections from the java.util
package.
Define layouts for multiple device orientations.
Use Android’s logging mechanism to log error messages.
5.2 Test-Driving the Flag Quiz App
5.2.1 Importing the App and Running It
5.3.3 Fragment Lifecycle Methods
5.3.8 Supporting Different Screen Sizes and Resolutions
5.3.9 Determining the Screen Size
5.3.10 Toast
s for Displaying Messages
5.3.11 Using a Handler
to Execute a Runnable
in the Future
5.3.12 Applying an Animation to a View
5.3.13 Logging Exception Messages
5.3.14 Using an Explicit Intent
to Launch Another Activity
in the Same App
5.4 Building the GUI and Resource Files
5.4.2 strings.xml
and Formatted String
Resources
5.4.6 activity_settings.xml
Layout
5.4.7 activity_main.xml
Layout for Phone and Tablet Portrait Orientation
5.4.8 fragment_quiz.xml
Layout
5.4.9 activity_main.xml
Layout for Tablet Landscape Orientation
5.4.10 preferences.xml
for Specifying the App’s Settings
5.4.11 Creating the Flag Shake Animation
5.5.1 package
Statement, import
Statements and Fields
5.5.2 Overridden Activity
Method onCreate
5.5.3 Overridden Activity
Method onStart
5.5.4 Overridden Activity
Method onCreateOptionsMenu
5.5.5 Overridden Activity
Method onOptionsItemSelected
5.5.6 Anonymous Inner Class That Implements OnSharedPreferenceChangeListener
5.6.1 package
Statement and import
Statements
5.6.3 Overridden Fragment
Method onCreateView
5.6.9 Anonymous Inner Class That Implements OnClickListener
Self-Review Exercises | Answers to Self-Review Exercises | Exercises