Answers for "how to check and uncheck single radio button in android"

1

how to check and uncheck single radio button in android

I have made a solution for it using set selected attribute of the radio button.

final RadioButton radioButton = findViewById(R.id.radioButton);
        radioButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!radioButton.isSelected()) {
                    radioButton.setChecked(true);
                    radioButton.setSelected(true);
                } else {
                    radioButton.setChecked(false);
                    radioButton.setSelected(false);
                }
            }
        });
Posted by: Guest on March-12-2021

Code answers related to "how to check and uncheck single radio button in android"

Browse Popular Code Answers by Language