A (175)

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

To access the Eclipse warning helper popup to see what Eclipse thinks is a problem with the
milkyWay object now that the constructor method call has been completed, mouse-over the
milkyWay object reference in your code.


The warning message at the top of the popup will tell you that “The value of the local variable
milkyWay is not used” because the milkyWay Galaxy object has not been used to do anything
(call any methods) as of yet.


It is also important to notice that Eclipse is calling milkyWay a variable, and not an object name,
telling us that milkyWay is actually a variable that’s referencing that particular Galaxy object,
created using the Java new keyword.


It is still OK for you to look at milkyWay as the name you use in your code to access this instance of
the Galaxy object. I just wanted to point out the finer detail in how the Java programming language
is viewing things here! The milkyWay variable, as Eclipse (Java) sees it, is a “pointer” or a memory
reference that accesses the Java object instance (that is, in this particular case, a Milky Way Galaxy
object definition and all its data values somewhere in system memory).


To remove this warning highlighting, make a method call, using dot notation, off of your new
milkyWay Galaxy object. Enter a return character at the end of the Galaxy object constructor line of
code, after the semi-colon, and create a new-line for your next line of code. Type in milkyWay and
hit the period key on your keyboard. This will open a different Eclipse helper popup, which contains
every method call that is compatible with this Galaxy object. As you can see in Figure 6-8, this
includes the four .set( ) methods that you coded in Chapter 5, which we are about to use here, to
set up the other properties of your milkyWay Galaxy object. We are doing this so when our UI design
accesses this object, it has data values to display!


Figure 6-7. Completing the Galaxy( ) constructor method call parameter list and mouse-over the warning to get tip

Free download pdf