A (175)

(Tuis.) #1

194 CHAPTER 6: Android Screen Design: Writing to the Display Using Activity and View


The easiest way to do this is to copy the galaxy_name through galaxyships string tag constants and
paste them underneath themselves. Remove galaxy
from the front of the string constant name, and
add _data to the end of the string constant name, so galaxy_name would become name_data, as
shown in Figure 6-25.


Adding a Second Nested LinearLayout Container to the UI Design


Now we can create the second nested container, right after the first
nested container. Since the parent container is arranging these horizontally, from
left to right, the second content (nested TextViews) will appear on the right side
of the UI design, as shown in Figure 6-20. Again, the easiest way to write all of this mark-up is to
select the entire first nested child LinearLayout and all of its TextView children and copy and paste it
underneath itself.


One of the concepts of fast program development is to copy, paste, and edit whenever possible!
Delete the first helloworld TextView tag from the second nested and leave only
the seven tags that are needed to hold Galaxy object attributes (variable data values),
as shown in Figure 6-26. Change the galaxy
references to the _data references so the
constants you just created occupy those TextView UI elements. If you now use the Run As ➤
Android Application menu sequence and look at your UI design, you will see only what you saw
after you added the first nested child tag, and you will not see the second nested


structure at all. Why? It looks like it’s time to discuss the UI layout constants!

Figure 6-25. Create seven objects to hold the seven data values (variables) for the Galaxy object

Free download pdf