SLIDE 3 3 Chapter 4 Tip Calculator App
c) Each component’s Relative weight determines how it should be sized relative to other components.
ANS: False. Each component’s Layout weight determines how it should be sized relative to
d) As with all Java programs, Android apps have a main method.
ANS: False. Android apps don’t have a main method.
e) An active (or running) activity is visible on the screen and “has the focus”—that is, it’s in the background. This is the activity the user is interacting with.
ANS: False. An active (or running) activity is visible on the screen and “has the focus”—
that is, it’s in the foreground. This is the activity the user is interacting with. f) A stopped activity is visible on the screen and is likely to be killed by the system when its memory is needed.
ANS: False. A stopped activity is not visible on the screen and is likely to be killed by the
system when its memory is needed. g) Method onCreate typically initializes the Activity’s instance variables and GUI com-
- ponents. This method should be as simple as possible so that the app loads quickly. In
fact, if the app takes longer than five seconds to load, the operating system will display an ANR (Application Not Responding) dialog—giving the user the option to forcibly terminate the app.
ANS: True.
Exercises
4.3 Fill in the blanks in each of the following statements: a) String literals should be placed in the strings.xml file in the app’s fold- er—especially if you intend to localize your app for use with multiple languages.
ANS: res/values.
b) You can control whether or not the user can give the focus to an EditText by setting its property.
ANS: Focusable.
c) A component’s specifies its relative importance with respect to other com- ponents.
ANS: Layout weight.
d) Class
- f package android.app provides the basic lifecycle methods of an
app.
ANS: Activity.
e) Interface
- f package android.text allows you to change the content and
markup of text in a GUI.
ANS: Editable.
f) You implement interface
- f package android.widget to respond to the
user moving the SeekBar’s thumb.
ANS: SeekBar.OnSeekBarChangeListener
g) Android apps have four types of components—activities, services, content providers and .
ANS: broadcast receivers.
h) Throughout its life an activity can be in one of several states—active (or running), paused or . The activity transitions between these states in response to var- ious events.
ANS: stopped.