532 CHAPTER 14: Android Content Providers: Providing Data to Applications
Once this is all in place, click on the Graphical Layout Editor tab at the bottom of the editing pane
and preview the TableLayout UI design. As you can see in Figure 14-21, the results are professional
with very little markup.
Figure 14-21. Use the Graphical Layout Editor tab to preview the TableLayout filled with Button UI elements
Now you are finally ready to get into Java coding, and write programming logic that will access these
databases.
ContactGalaxy Class: Accessing Your Database
As you know by now, the first step in the process of coding your ContactGalaxy.java Activity
subclass is to declare and instantiate your UI Button objects. These are contained inside the parent
TableLayout container, which you defined in the activity_contact.xml file in the /res/layout folder in
the previous section of the chapter.
Declare all five of your Button objects at the top of your ContactGalaxy class by using the one class
declaration with multiple object names trick that I explained earlier in this book. This can be done by
using the following single line of Java code, which is shown in Figure 14-22:
Button listButton, milkyWayButton, andromedaButton, spiralButton, homeButton;