January 2017
Beginner to intermediate
624 pages
22h 42m
English
In the previous chapter, there was not much happening in GeoQuiz’s one controller, QuizActivity. It displayed the layout defined in activity_quiz.xml. It set listeners on two buttons and wired them to make toasts.
Now that you have multiple questions to retrieve and display, QuizActivity will have to work harder to tie GeoQuiz’s model and view layers together.
Open QuizActivity.java. Add variables for the TextView and the new Button. Also, create an array of Question objects and an index for the array.
Listing 2.6 Adding variables and a Question array (QuizActivity.java)
public class QuizActivity extends AppCompatActivity {
private Button mTrueButton;
private Button mFalseButton;
private Button ...Read now
Unlock full access