A (175)

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

If you mouse-over the error, you will see that Eclipse is telling you that “The method
setGalaxyColonies(long) in the (object) type Galaxy is not applicable for the arguments (int, int,
int).” This lets you know Eclipse is evaluating those comma characters in your numeric designation
as value delimiters, not as numeric formatting, which you were using to try and indicate (signify) a
large (millions) numeric representation.


This means that Eclipse (and thus the compiler) will think you are passing three integer values
into the method call, rather than one large, accurately formatted number! The solution to this is,
of course, to not use commas in your numeric values in method call parameter lists, as parameter
values are separated, or “delimited,” using Programmer speak, by using the comma character. We
can always provide this numeric formatting once we pass a data value from the Galaxy object to
each TextView, which we will be doing much later on in the chapter using Java code.


Note that none of these three “quick fixes” in this particular pop-up will solve the problem, so you
will have to remove the commas yourself! Don’t be surprised if someday Eclipse ADT features a
higher level of artificial intelligence in their helper code analysis algorithm that will add in a fourth
quick fix option of “Remove comma delimiters to create the required long data value.” The reason I
am generating these errors and warnings in this section is so that I can show you all these Eclipse
helper popups and how to use them.


Once you remove these commas from your numeric data value, the error will vanish, and you
can use this same work process of typing in the Galaxy object variable name of milkyWay and a
period, and double-click on each of the remaining three method calls, to set the population at
1,967,387,132 (without commas, of course), set the number of fleets to 237 , and set the number of
starships to 34,769, without using the comma, as is shown in Figure 6-10. Note that all of the Java
code is error-free and you have created and configured the milkyWay Galaxy object and all of its
data fields (its characteristics) for your MainActivity.java class, using only five compact lines of Java
program logic.


Figure 6-10. Completed Galaxy object construction and configuration using Galaxy class method calls

Free download pdf