Guys, in onCreateDialog i have this:
case DIALOG_REVIEW: {
if (bundle.containsKey("POSITION")) {
final int position = bundle.getInt("POSITION");
ArrayList<String> alterNumbers = numbers.get(position);
final String[] phoneNums = new String[alterNumbers.size()];
for (int i = 0; i < alterNumbers.size(); i++) {
phoneNums[i] = alterNumbers.get(i);
}
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle(names.get(position) + "'s number(s)");
dialog.setSingleChoiceItems(phoneNums, 0,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
// get selected item and close the dialog
String selectedNumber = phoneNums[which];
updateUserSelectedNumber(position , selectedNumber);
}
});
return dialog.create();
}
which is working and great.
BUT pay attention to line
dialog.setSingleChoiceItems(phoneNums, 0,
new DialogInterface.OnClickListener() {
phoneNums are suppose to be changing each time the dialog pops up. I've overriden onPrepareDialog method but I don't know how to assign new values to it. and also there is no setSingleChoiceItems there.
here is my onPrepareDialog method
case DIALOG_REVIEW: {
final int position = bundle.getInt("POSITION");
ArrayList<String> alterNumbers = numbers.get(position);
final String[] phoneNums = new String[alterNumbers.size()];
for (int i = 0; i < alterNumbers.size(); i++) {
phoneNums[i] = alterNumbers.get(i);
}
AlertDialog alertDialog = (AlertDialog) dialog;
alertDialog.setTitle(names.get(position) + "'s number(s)");
???
break;
}
What is the solution? thanks in advance guys.