A (175)

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

Make sure that the Build Automatically option on the Project menu has a check mark to the left
of it, which it should, since this is the default setting in Eclipse. This auto-build option is directly
underneath the Clean submenu option.


Once the Clean dialog opens up, click on the radio button next to the “Clean projects selected
below” and then make sure that the check box next to the HelloUniverse project is checked, and
then click the OK button, which will then “clean” and finally “rebuild” your Hello Universe project.


If this does not get rid of the errors in the IDE, which it didn’t when I tried it, then exit Eclipse again,
and restart it again, accept the workspace location dialog, and then wait for a few minutes for
Eclipse to look for and to find the JDK on your hard drive. We know it’s there, because we would not
have made it past Chapter 2 of this book if it wasn’t!


This finally worked on my workstation, and I finally got the clean project that I should have gotten in
the first place, when I started working on all of this today. The clean IDE, shown in Figure 6-5 with
zero Java code errors, which I knew to be the case, and the “empty” Problems tab shown at the
bottom, shows me that Eclipse ADT has found, and is now referencing (I like to call it “wired up to”),
the java.lang.Object class inside the Java SDK.


Figure 6-5. Once visibility to Java SDK (java.lang.Object) has been restored, all the incorrect error tags disappear


Next, let’s construct the new Galaxy Object, and name it milkyWay, using the Galaxy( ) method, so
that we can use the impressive code that you created in Chapter 5 for something useful in your Hello
Universe application.


Using the Galaxy Class: Creating a Galaxy Object


As you learned in Chapter 5, the way to construct an object is by calling the constructor method; in
this case, it is the Galaxy( ) method, in conjunction with the Java new keyword, utilizing the following
Java code structure:


Galaxy milkyWay = new Galaxy();

Free download pdf