Sams Teach Yourself Java™ in 24 Hours (Covering Java 7 and Android)

(singke) #1
ptg7068951

362 HOUR 24:Writing Android Apps


16.Expand Drawable, choose whitehouse, and click OK. Agraphic of
the White House becomes the screen’s background.
17.Click the Save button.

The finished screen appears in Figure 24.15.

FIGURE 24.15
Previewing an app’s graphical user
interface.


Writing Java Code
At this point you’vedone the bulk of the work on the new app, but you
haven’t written a single line of Java code. App development is easier when
you utilize as many capabilities of the Android SDK as possible without
resorting to programming.
Apps are organized into Activities, which represent things an app can do.
Each Activity is defined by its own Java class. When you created this app,
you specified that an Activity named LeaderActivityshould be created. A
class matching this name runs automatically when the app is loaded.
The source code for LeaderActivity.javacan be found in Package
Explorer in the /src/org.cadenhead.androidfolder. Double-click this file
to edit it.
When you start, the class has the code in Listing 24.1.
Free download pdf