March 2013
Beginner to intermediate
580 pages
16h 11m
English
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)
public class QuizActivity extends Activity {
private Button mTrueButton;
private Button mFalseButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz);
}
...
}
You will fix the errors in just a second. First, notice the m prefix on the two member (instance) variable names. This prefix is an Android naming convention ...
Read now
Unlock full access