how to know which radio button is selected in android code example
Example: 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);
}
}
});