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. need to build custom calendar

i want to create a custom calendar
can i use GridView for that ?
how to create it  (without using 2D/3D api) ?

2. View.removeCallbacks problem

Let's say that there are two threads... a thread that waits for a
package from a server and the UI thread. When the package arrives, the
network thread calls runOnUIThread() with an anonymous implementation
of the Runnable interface which displays a PopupWindow. The popup must
be visible for X ms, so the View contained in the PopupWindow calls
postDelayed(<dismiss the popup>, X). Everything works fine, but now I
want to hide the Popup when the user touches the screen. I made the
popup focusable & touchable outside. When I capture the ACTION_DOWN
event I first call removeCallbacks(<the same runnable object used in
the postDelayed above>) and then dimiss() the popup. The problem with
this is that the removeCallbacks doesn't delete the action posted in
the first place and after the popup is gone the action is still

Any ideas about what could generate such behavior?

3. Cannot get PhoneNumber on Real device but code works in Emulator

4. Enable / Disable android widgets runtime.

5. System.setProperty() cannot change system property in Android

6. How to increase/decrease the volume programmatically?

7. How to increase/decrease the volume programmatically?