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. Retrieving GRP Coordinates, getting errors with getLastKnownLocation and requestLocationUpdates

I tried the below code and it s working fine

Criteria c = new Criteria();
        locationMgr = (LocationManager)
            bestP = locationMgr.getBestProvider(c, true);
                isGpsEnabled = locationMgr.isProviderEnabled(bestP);

                if (isGpsEnabled)
                         Location location =
                        locationMgr.requestLocationUpdates(bestP, 100, 1, 

Try this..........




2. Audio input from Bluetooth


if I understand correctly, getting audio input from a Bluetooth mic/headset,
using say AudioRecord, is not supported. Is this right?



3. SOLD ! WTS: HTC Desire BNIB only 1 unit

4. Odp: A simplest Application access "Content Provider"

5. Title bar display

6. troubles reading other apps config files

7. When I override Adapter.isEnabled() the ListView divider isn't displayed