1

I've created an alertdialog that has a list of radiobuttons using setSingleChoiceItems and try to set one or more buttons checked when the user clicked it. For example, if the user selected an item, it shows the item checked when it opens again. However, if the user selected another item next time, now it shows both buttons checked.

Therefore, I am trying to get a radiobutton from my alertdialog so I can set it checked manually since the code needs to have more than two buttons checked. if anyone has an idea, would you please help me? Below is my code.


private void CreateAlertDialog(){
        ab = new AlertDialog.Builder(Main.this)
        .setTitle(R.string.menu_sortby)
        .setSingleChoiceItems(R.array.sort_by_items, -1, new DialogInterface.OnClickListener() {                        
            public void onClick(DialogInterface dialog, int which) {                    
                radioButtonIndex = which;
                dialog.dismiss();
            }
        });
    }
June
  • 265
  • 1
  • 8
  • 21

1 Answers1

0

Take a look at How to persist options selected in AlertDialog spawned from ItemizedOverlay onTap method

Community
  • 1
  • 1
Thane Anthem
  • 4,093
  • 4
  • 26
  • 24