Time for action - adding a space for answers

While posing a question to the user is all very fine and well, we need to give them some way to answer that question. We have several possibilities at our disposal: We could use a RadioGroup with a RadioButton for each possible answer, or a ListView with an item for each answer. However, to minimize the required interaction, and make things as clear as possible, we use one Button for each possible answer. However, this complicates things slightly, since you can't declare a variable number of Button objects in your layout XML file. Instead, we will declare a new LinearLayout and populate it with Button objects in the Java code.

  1. Under the TextView where we pose our question, you will need to add a<LinearLayout ...

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.