开发者

How to get a selected button in AlertDialog?

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();
            }
        });
    }


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜