O'Reilly logo

Android Programming: The Big Nerd Ranch Guide by Brian Hardy, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

From Layout XML to View Objects

How do XML elements in activity_quiz.xml become View objects? The answer starts in the QuizActivity class.

When you created the GeoQuiz project, a subclass of Activity named QuizActivity was created for you. The class file for QuizActivity is in the src directory of your project. The src directory is where the Java code for your project lives.

In the package explorer, reveal the contents of the src directory and then the contents of the com.bignerdranch.android.geoquiz package. Open the QuizActivity.java file and take a look at its contents (Listing 1.4).

Listing 1.4  Default class file for QuizActivity (QuizActivity.java)

p​a​c​k​a​g​e​ ​c​o​m​.​b​i​g​n​e​r​d​r​a​n​c​h​.​a​n​d​r​o​i​d​.​g​e​o​q​u​i​z​;​ i​m​p​o​r​t​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required