5. Flag Quiz App


Objectives

In this chapter you’ll:

Image Use Fragments to make better use of available screen real estate in an Activity’s GUI on phones and tablets.

Image Display an options menu on the action bar to enable users to configure the app’s preferences.

Image Use a PreferenceFragment to automatically manage and persist an app’s user preferences.

Image Use an app’s assets subfolders to organize image resources and manipulate them with an AssetManager.

Image Define an animation and apply it to a View.

Image Use a Handler to schedule a future task to perform on the GUI thread.

Image Use Toasts to display messages briefly to the user.

Image Launch a specific Activity with an explicit Intent.

Image Use various collections from the java.util package.

Image Define layouts for multiple device orientations.

Image Use Android’s logging mechanism to log error messages.



Outline

5.1 Introduction

5.2 Test-Driving the Flag Quiz App

5.2.1 Importing the App and Running It

5.2.2 Configuring the Quiz

5.2.3 Taking the Quiz

5.3 Technologies Overview

5.3.1 Menus

5.3.2 Fragments

5.3.3 Fragment Lifecycle Methods

5.3.4 Managing Fragments

5.3.5 Preferences

5.3.6 assets Folder

5.3.7 Resource Folders

5.3.8 Supporting Different Screen Sizes and Resolutions

5.3.9 Determining the Screen Size

5.3.10 Toasts 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.3.15 Java Data Structures

5.4 Building the GUI and Resource Files

5.4.1 Creating the Project

5.4.2 strings.xml and Formatted String Resources

5.4.3 arrays.xml

5.4.4 colors.xml

5.4.5 dimens.xml

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 MainActivity Class

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 QuizFragment Class

5.6.1 package Statement and import Statements

5.6.2 Fields

5.6.3 Overridden Fragment Method onCreateView

5.6.4 Method updateGuessRows

5.6.5 Method updateRegions

5.6.6 Method resetQuiz

5.6.7 Method loadNextFlag

5.6.8 Method getCountryName

5.6.9 Anonymous Inner Class That Implements OnClickListener

5.6.10 Method disableButtons

5.7 SettingsFragment Class

5.8 SettingsActivity Class

5.9 AndroidManifest.xml

5.10 Wrap-Up

Self-Review Exercises | Answers to Self-Review Exercises | Exercises


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.184.29