Android How to Program Chapter 05 Solution Manual
Download file with the answers
Android How to Program Chapter 05 Solution Manual
1 file(s) 272.44 KB
If you are not a member register here to download this file
Favorite Twitter® 5
Searches App
Objec t ives
In this chapter you’ll:
■ Enable users to interact with
an app via Buttons.
■ Use a ScrollView to
display objects that do not fit
on the screen.
■ Create GUI components
dynamically in response to
user interactions by inflating
an XML layout.
■ Store key/value pairs of data
associated with an app using
SharedPreferences.
■ Modify key/value pairs of
data associated with an app
using SharedPreferences.
Editor.
■ Create AlertDialogs with
an AlertDialog.Builder.
■ Programmatically open a
website in a web browser by
using an Intent.
■ Programmatically hide the
soft keyboard.
■ Learn about the file
AndroidManifest.xml.
2 Chapter 5 Favorite Twitter® Searches App
Self-Review Exercises
5.1 Fill in the blanks in each of the following statements:
a) (Self Review) are typically used to launch activities—they indicate an action
to be performed and the data on which that action is to be performed.
b) (Self Review) We implement interface to handle the events that occur
when the user touches a button on an AlertDialog.
c) (Self Review) Lengthy data access should never be done in the UI thread; otherwise, the
app will display an dialog—typically after five seconds of inactivity.
d) (Self Review) An Intent is a description of an action to be performed with associated
.
e) (Self Review) Intents specify an exact Activity class to run in the same
app.
f) (Self Review) When you create the project for each Android app in Eclipse, the ADT
Plugin creates and configures the file (also known as the app’s manifest),
which describes information about the app.
g) (Self Review) The attribute specifies the app’s name.
h) (Self Review) Within the activity element is the element, which specifies
the types of intents the Activity can respond to.
5.2 State whether each of the following is true or false. If false, explain why.
a) (Self Review) (True/False) Extensive input/output should be performed on the UI
thread, otherwise that would affect your app’s responsiveness.
b) (Self Review) (True/False) A benefit of defining dimensions as resources is that you can
use density-independent pixel (dp or dip) and scale-independent pixel (sp) values,
which Android automatically converts to the appropriate pixel values for a given device.
c) (Self Review) (True/False) You call toArray (with an empty String array as an argument)
on the Set object to convert the Set into an array of Strings.
Exercises
5.3 Fill in the blanks in each of the following statements:
a) (Exercise) A is a ViewGroup that can contain other Views (like a layout) and
that lets users scroll through content too large to display on the screen.
d) (Exercise) The inflates an XML layout file, thus creating the components
specified in the XML.
Exercises 3
e) (Exercise) A layout fills the entire screen if the Layout width and Layout height properties
have the value .
f) (Exercise) The method is called by the system when the app loads, if the
app’s process was killed by the operating system while the app was in the background,
and the app is then restored, each time the configuration changes, such as when the user
rotates the device or opens/closes a physical keyboard.
g) (Exercise) (a static method of class Arrays from package java.util)
sorts the array in its first argument.
h) (Exercise) You use objects to configure and create AlertDialogs for displaying
messages to the user.
5.4 State whether each of the following is true or false. If false, explain why.
a) (Exercise) (True/False) An Algorithm specifies an action to be performed and the data
to be acted upon—Android uses Algorithms to launch the appropriate activities.
b) (Exercise) (True/False) You implement interface View.OnClickListener of package android.
view to specify the code that should execute when the user touches a Button.
c) (Exercise) (True/False) The first argument passed to Intent’s constructor is the data to
be operated on.
d) (Exercise) (True/False) With an explicit Intent, we allow the system to launch the
most appropriate Activity based on the type of data.
e) (Exercise) (True/False) If you don’t provide your own icon, the app uses the icon that’s
supplied by the ADT Plugin when you create the app’s project.
f) (Exercise) (True/False) The category element value “android.application.category.
LAUNCHER” indicates that this activity should be listed in the application launcher
with other apps on the device.
Leave a reply