AlertDutog中的RadioButton或Or CheckBox

时间:2011-03-01 12:30:01

标签: android android-checkbox

如何在RadioButtons中使用多个CheckBoxesAlertDialog

1 个答案:

答案 0 :(得分:8)

试试这个代码......

    final CharSequence[] gender = {"Male","Female"};
    AlertDialog.Builder alert = new AlertDialog.Builder(uploadphoto.this);
    alert.setTitle("Select Gender");
    alert.setSingleChoiceItems(gender,-1, new DialogInterface.OnClickListener()
    {
        @Override
        public void onClick(DialogInterface dialog, int which) 
        {
            if(gender[which]=="Male")
            {
                gen="1";
            }
            else if (gender[which]=="Female")
            {
                gen="2";
            }
        }
    });
    alert.show();
相关问题