Multiple - multiple choice dialogs/activities, questionnaire, one question at the time

by John Smith » Tue, 27 Apr 2010 05:04:51 GMT

Sponsored Links
 Hi there,

I am new at developing for android, so bear with me (and my ignorance).

I have tried to make a series of dialogs, like a questionnaire, that the
user needs to answers a series of questions selecting one or more
checkboxes. I can do one, just fine, but when I try to make more than one
question (lets say 10), it does not show, or show all the dialogs. I tried
using dialogs or new acitivities.

So, my problem is I have multiple questions, one to be presented each time,
and I need to wait for one to be responded so I can ask the next one. How do
I accomplish this?

My first attempt was with a dialog box... but obviously it got all the boxes
stacked in each other:

 for (int i = 0; i < questions.size(); i++) {

final int counter = i;
 int size = questions.size();
CharSequence[] itemsBuilder = new CharSequence[size];
 boolean[] bitemsBuilder = new boolean[size];

for (int j = 0; j < questions(i).getPossibleAnswers().size(); j++) {
 itemsBuilder[j] = quastions(i).getPossibleAnswers().get(j);
bitemsBuilder[j] = false;

final CharSequence[] items = itemsBuilder;
final boolean[] bitems = bitemsBuilder;
 AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Choose the answer for "
 + question.get(i).getQuestion();
builder.setMultiChoiceItems(items, bitems,
 new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialog, int item,
 boolean choice) {
Log.d("choice", "" + item + " " + choice);
items[item], Toast.LENGTH_SHORT).show();
 new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {

AlertDialog alert = builder.create();;

John Romero


Other Threads

1. How to show alert message.

Hi all,

I am very new to the android platform.

I have created an activity that makes a call on the number entered by

Now i want to validate the user input.

There was supposed to be a alert box method as below

showAlert(CharSequence title, CharSequence message, CharSequence
buttonText, boolean cancelable);

But there is no more sign of this method. So i couldn't get the way to
display a simple alert message.

Any help is appreciated



2. Early boot process of the Android G1 dev phone

Does anybody know if there is somewhere a doc explaining the early
boot sequence of the Android dev phone ( G1 ) ?

Does the ADP use uboot ? How to take the hand on it when the
bootloader start, before the launching of the kernel ?

May be this doc could also describe how to completely reflash the
device ( boot loader, kernel, filesystem,...)

Considering that this phone is currently a reference design, detailing
this part of the process sounds useful to any new port, doesn't it ?

Thanks for you inputs !



3. Adding Custom Hardware?

4. Android Dev Phone 1鈩

5. File access for native code

6. Save data between onDestory/onCreate cycles

7. How do you start a service on installation?