July 2015
Beginner to intermediate
600 pages
18h 59m
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 code completion; type it in yourself.) After you save the file, it will report two errors.
Listing 1.7 Adding member variables (QuizActivity.java)
public class QuizActivity extends AppCompatActivity {
private Button mTrueButton;
private Button mFalseButton;
@Override
protected 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 ...
Read now
Unlock full access