Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I just faced the same problem:</p> <p>Two solutions:</p> <p>1/ The fast and dirty</p> <p>Delete the Dialog each time you have finished with it => onPrepareDialog will not be called so you wont have problems with data update:</p> <pre><code>protected Dialog onCreateDialog(int id) { ... case DIALOG_REVIEW: { 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); removeDialog(DIALOG_REVIEW); } }); return dialog.create(); } </code></pre> <p>if you prefer, you can put a <a href="http://developer.android.com/guide/topics/ui/dialogs.html#DismissingADialog">onDismissListener</a> and do the removeDialog on the dialog dismiss.</p> <hr> <p>2/ The quite pretty one</p> <p>In the onPrepareDialog method just replace the old ArrayAdapter used by the dialog by a fresh new one:</p> <pre><code>@Override protected void onPrepareDialog(int id, Dialog dialog) { switch (id) { case DIALOG_REVIEW: ArrayAdapter&lt;CharSequence&gt; adapter = new ArrayAdapter&lt;CharSequence&gt;(this, android.R.layout.select_dialog_singlechoice, android.R.id.text1, phoneNums); AlertDialog ad = (AlertDialog) dialog; ad.getListView().setAdapter(adapter); break; default: super.onPrepareDialog(id, dialog); } } </code></pre> <p>I use the same method than the one used by android (the AlertController.java L. 854 of the froyo source code) to populate the dialog the first time.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload