Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to set contents of setSingleChoiceItems in onPrepareDialog?
    primarykey
    data
    text
    <p>Guys, in onCreateDialog i have this: </p> <pre><code>case DIALOG_REVIEW: { if (bundle.containsKey("POSITION")) { final int position = bundle.getInt("POSITION"); ArrayList&lt;String&gt; alterNumbers = numbers.get(position); final String[] phoneNums = new String[alterNumbers.size()]; for (int i = 0; i &lt; 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(); } </code></pre> <p>which is working and great.</p> <p>BUT pay attention to line </p> <pre><code>dialog.setSingleChoiceItems(phoneNums, 0, new DialogInterface.OnClickListener() { </code></pre> <p>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.</p> <p>here is my onPrepareDialog method</p> <pre><code>case DIALOG_REVIEW: { final int position = bundle.getInt("POSITION"); ArrayList&lt;String&gt; alterNumbers = numbers.get(position); final String[] phoneNums = new String[alterNumbers.size()]; for (int i = 0; i &lt; alterNumbers.size(); i++) { phoneNums[i] = alterNumbers.get(i); } AlertDialog alertDialog = (AlertDialog) dialog; alertDialog.setTitle(names.get(position) + "'s number(s)"); ??? break; } </code></pre> <p>What is the solution? thanks in advance guys.</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.
 

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