3.1 Fill in the blanks in each of the following statements:
a) A(n) _____________—often called a text box or text field in other GUI technologies—is a subclass of TextView
that can display text and accept text input from the user.
b) Use a(n) _____________to arrange GUI components into cells in a rectangular grid.
c) When working with more complex layouts like GridLayout
s, it’s difficult to see the nested structure of the layout and to place components in the correct nested locations using the Visual Layout Editor. The _____________ window makes these tasks easier because it shows the nested structure of the GUI. So, in a GridLayout
, you can select the appropriate row and add a GUI component to it.
d) Class _____________ of package android.os
represents an app’s state information.
e) You implement interface _____________ of package android.text
to respond to events when the user interacts with an EditText
component.
f) A separate _____________ is typically associated with each screen of an app.
g) The method _____________ is called by the system when an Activity
is starting—that is, when its GUI is about to be displayed so that the user can interact with the Activity
.
h) As you build your app’s GUI and add resources (such as string
s in the strings.xml
file or GUI components in the activity_main.xml
file) to your app, the IDE generates a class named _____________ that contains nested static
classes representing each type of resource in your project’s res
folder.
i) Class _____________ (nested in class R
)—contains constants for any drawable
items, such as images, that you put in the various drawable
folders in your app’s res
folder.
j) Class _____________ (nested in class R
)—contains constants for each String
in the strings.xml
file.
k) Once the layout is inflated, you can get references to the individual widgets using Activity
’s _____________ method. This method takes an int
constant for a specific view (that is, a GUI component) and returns a reference to it.
3.2 State whether each of the following is true or false. If false, explain why.
a) Method onCreate
typically initializes the Activity
’s instance variables and GUI components. 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.
b) Each component’s relative Weight determines how it should be sized relative to other components.
c) As with all Java programs, Android apps have a main
method.
d) An active (or running) activity is visible on the screen and “has the focus”—that is, it’s in the background.
e) A stopped activity is visible on the screen and is likely to be killed by the system when its memory is needed.