Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Change second argument (checkedItem) in <code>setSingleChoiceItems</code> from -1 to what ever position of radio button you wanted to be checked, here i changed it to '1' so first radio button will be checked. </p> <pre><code> alertDialogBuilder.setSingleChoiceItems(items, 1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(SettingAppDisplay.this, "You selected item No." + item + ": " + items[item], Toast.LENGTH_SHORT).show(); if (items[item].equals("5")) { //do what you want } else if (items[item].equals("10")) { //do what you want } else if (items[item].equals("15")) { //do what you want } else if (items[item].equals("20")) { //do what you want } dialog.dismiss(); } }); </code></pre> <p>See <a href="http://developer.android.com/reference/android/app/AlertDialog.Builder.html#setSingleChoiceItems%28android.database.Cursor,%20int,%20java.lang.String,%20android.content.DialogInterface.OnClickListener%29" rel="noreferrer">docs</a></p> <pre><code>setSingleChoiceItems (Cursor cursor, int checkedItem, String labelColumn, DialogInterface.OnClickListener listener) </code></pre> <p><strong>Parameters</strong></p> <p><em><strong>cursor</em></strong> the cursor to retrieve the items from.</p> <p><em><strong>checkedItem</em></strong> specifies which item is checked. If -1 no items are checked.</p> <p><em><strong>labelColumn</em></strong> The column name on the cursor containing the string to display in the label.</p> <p><em><strong>listener</em></strong> notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog.</p>
    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.
    1. VO
      singulars
      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