i would like to show a number of alertdialogs so the user has to handle off some questions (a little like a wizzard)
is it possible to make the alertDialog wait until the user chooses something and then returning the choisen value?
HashMap<Integer, Question> questions = DataConnector.getCallQuestions(position);
int nextQuestion = position;
while(nextQuestion != 0){
Question question = questions.get(nextQuestion);
CharSequence[] items = (String[])question.getAnswers();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(question.getQuestion());
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
}
});
AlertDialog alert = builder.create();
//i would like to do something like this:
nextQuestion = alert.getClickedItem();
}
EDIT reponse to chris
the execution of the program should wait until the user chooses 1 of the options in the alertDialog
is this possible?
like this:
private int answer = 0;
....
...methode(){
//show dialog
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(question.getQuestion());
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
CallHandleMenu.this.answer = item; //setting answer
}
});
builder.create().show();
//here i need to know answer (answer should not be 0 here)