Time for action - putting the questions on the screen

Your application now knows where to find the questions to ask, and knows which question it should be asking. Now it needs to put the question on the screen, and allow the user to select an answer.

  1. Open the main.xml file in your editor or IDE.
  2. Remove the Yes!, No!, and Maybe? Button elements from the layout resource.
  3. Open the QuestionActivity.java file in an editor or IDE.
  4. We will need a new class field to hold the dynamically-created Button objects (for reference):
    private Button[] buttons;
  5. In order to keep things neat, create a new private method to put the questions on the screen: initQuestionScreen:
    private void initQuestionScreen() {
  6. In this method, we assume that the layout XML file has already ...

Get Android User Interface Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.