Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid - How to update the status multichoice items of alert dialog
    primarykey
    data
    text
    <p>In my application, I am displaying the alert dialog if you click on a button. The alert dialog consists of multi choice items and 2 buttons(i.e, Ok and Cancel). Initially I set some items using array(i.e., in code choice_checked).</p> <ol> <li><p>If you open the alert dialog you did some changes and click on the ok button then dialog dismiss and once again open the alert dialog then it shows the changes(i.e, this default property of alert dialog). </p></li> <li><p>If you open the alert dialog you did some changes and click on the cancel button then dialog dismiss and once again open the alert dialog in this case i want to show the previous status only(don't show the changes).i tried but i am not getting please can any body help me.</p></li> <li><p>In the code choice_checked and choice_checked_dynamic are the boolean arrays.choice_checked_dynamic is the duplicate of choice_checked. Means Initially these two arrays are same. If you did some changes in the list and click on the ok button then the changed array is copied into the choice_checked_dynamic. By default alert dialog shows the changes only so it is fine for ok button. But in case of cancel button, means if you did some changes then click on the cancel button then i want to display the choice_checked_dynamic status(means i displayed the previous status ). </p></li> </ol> <p>I tried but i am not getting please Can anybody help me.</p> <p>Code:</p> <pre><code>private OnClickListener bookmark_btnListener = new OnClickListener() { public void onClick(View v) { try { showDialog(DIALOG_MULTI_CHOICE); } catch(Exception ex2) { System.out.println("back btn error:"+ex2.toString()); } } }; protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_MULTI_CHOICE: bookmark_dialog = new AlertDialog.Builder(this); bookmark_dialog.setTitle("Bookmarking for"); bookmark_dialog.setMultiChoiceItems(choice, choice_checked, new OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int index, boolean status) { } }); bookmark_dialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { for(int i=0;i&lt;choice_checked.length;i++) { choice_checked_dynamic[i] = choice_checked[i]; } dialog.dismiss(); } }); bookmark_dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { for(int i=0;i&lt;choice_checked_dynamic.length;i++) { choice_checked[i] = choice_checked_dynamic[i]; } dialog.dismiss(); } }); return bookmark_dialog.create(); } return null; } </code></pre>
    singulars
    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.
 

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