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

Wiring Up Widgets

Now that the buttons have resource IDs, you can access them in QuizActivity. The first step is to add two member variables.

Type the following code into QuizActivity.java. (Do not use auto-complete; type it in yourself.) After you save the file, it will report two errors.

Listing 1.8  Adding member variables (QuizActivity.java)

p​u​b​l​i​c​ ​c​l​a​s​s​ ​Q​u​i​z​A​c​t​i​v​i​t​y​ ​e​x​t​e​n​d​s​ ​A​c​t​i​v​i​t​y​ ​{​

 ​ ​ ​ ​p​r​i​v​a​t​e​ ​B​u​t​t​o​n​ ​m​T​r​u​e​B​u​t​t​o​n​;​
 ​ ​ ​ ​p​r​i​v​a​t​e​ ​B​u​t​t​o​n​ ​m​F​a​l​s​e​B​u​t​t​o​n​;​ ​ ​ ​ ​@​O​v​e​r​r​i​d​e​ ​ ​ ​ ​p​u​b​l​i​c​ ​v​o​i​d​ ​o​n​C​r​e​a​t​e​(​B​u​n​d​l​e​ ​s​a​v​e​d​I​n​s​t​a​n​c​e​S​t​a​t​e​)​ ​{​ ​ ​ ​ ​ ​ ​ ​ ​s​u​p​e​r​.​o​n​C​r​e​a​t​e​(​s​a​v​e​d​I​n​s​t​a​n​c​e​S​t​a​t​e​)​;​ ...

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