Friday, October 30, 2009

[android-developers] AlertDialog setSingleChoiceItems

Hello,

I have an AlertDialog with single choice items, but these items
sometimes change, so I have to update the radiobuttons array every time
when the dialog is showed.
I know there is a method called onPrepareDialog but the Dialog doesn't
have the setSingleChoiceItems, only the Builder.

Here is my onCreateDialog:

protected Dialog onCreateDialog(int id) {
Dialog dialog;

case DIALOG_SOMETHING:
{
final CharSequence[] radiobuttons;
int checked;

//... here I fill radiobuttons array and set
the checked item.

// create dialog
AlertDialog.Builder builder = new
AlertDialog.Builder(this);
builder.setTitle("title")
.setSingleChoiceItems(radiobuttons, checked, new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int radioitem)
{
// ...
}
})
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id)
{
// ...
}
});

dialog = builder.create();

break;
}


default:
dialog = null;
}

return dialog;
}


If I copy this code to onPrepareDialog, nothing happens. :-( The
dialog doesn't update my radiobuttons.
What can I do?

Evi

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments:

Post a Comment