RadioButton or CheckBox in AlertDialog

How to use multiple RadioButtonsor CheckBoxesin AlertDialog?

+3
source share
1 answer

Just try this code ....

    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();
+8
source

Source: https://habr.com/ru/post/1795478/


All Articles