CHAPTER 6: Android Screen Design: Writing to the Display Using Activity and View 199
As you can see in Figure 6-29, the first time you use any class reference in your Java code that
has not been specifically “imported” for use in your code, you will get the wavy red underline
highlighting underneath it.
Figure 6-29. Declaring a TextView object named nameData at the top of the MainActivity class to hold UI values
If you place (termed “hovering” in computer speak) your mouse over the error highlight, you will get
the pop-up telling you the TextView cannot be resolved, because Eclipse does not know what it is
yet. The first of eight solutions to this problem happens to be the “correct” one, so click on Import
‘TextView’ (android.widget), which will instruct Eclipse to write this import statement for you.
As you can see in Figure 6-30, the Java import statement has been inserted (highlighted in light
blue in the IDE) after the three existing import statements, and before the class declaration. As you
will also notice, the error highlighting has vanished, and you are ready to copy and paste this first
nameData TextView UI object declaration six more times underneath itself, which will create all seven
“updateable” TextView UI widget objects, all of which are defined to “live” inside of your second
nested