A (175)

(Tuis.) #1
CHAPTER 6: Android Screen Design: Writing to the Display Using Activity and View 181

Adding constants for Your UI Labels


Once this has been edited, copy and paste this constant definition tag seven times
underneath itself, and then create text string constants for galaxy_name, galaxy_solar,
galaxy_habit, galaxy_colony, galaxy_pop, galaxy_fleet, and galaxy_ships named constants,
as shown in Figure 6-12, using the following XML mark-up:


Galaxy Name:
Galaxy Solar Systems:
Galaxy Habitable Planets:
Galaxy Colonies:
Galaxy Population:
Galaxy Starship Fleets:
Galaxy Active Starships:

Figure 6-12. Change the hello_world variable to a new screen title; create the eight galaxy info tags


Using Parameters to Configure Your LinearLayout


Now that we have the galaxy information screen’s data value holder string constants defined,
we can configure the LinearLayout UI layout container. As you can probably infer from the class
name, a LinearLayout class is used to create either rows of horizontal UI elements, or columns of
vertical UI elements, as we are doing here with vertically stacked TextView UI elements (widgets).
Let’s tell the parent tag how to orient its child tag View UI widgets by adding the
android:orientation parameter. To get the helper dialog containing all of the parameters that are
available for use with the LinearLayout class, type in the word “android” and then type a colon and
wait a second for the Eclipse child tag helper dialog to appear, as is shown in Figure 6-13.

Free download pdf