Code example for RadioGroup

Methods: getCheckedRadioButtonId, findViewById

0
                .setView(layout)
                .setPositiveButton("Подписаться", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
 
                        View v = emailtype_radio.findViewById(emailtype_radio.getCheckedRadioButtonId());
                        String emailtype = "delayed";
                        if (v == emailnone_radio) {
                            emailtype = "none";
                        } else if (v == emaildelayed_radio) {
                            emailtype = "delayed";
                        } else if (v == emailimmediate_radio) {
                            emailtype = "immediate";
                        } else if (v == emaildaily_radio) {
                            emailtype = "daily";
                        } else if (v == emailweekly_radio) {
                            emailtype = "weekly";
                        } 
 
                        Toast.makeText(context, "Запрос на подписку отправлен", Toast.LENGTH_SHORT).show();