I used the following code snippet to disable one radio button if another is selected, but when I launch the application and select both radio buttons, the code does not work, since both options remain selected.
I use a relative format, so I can’t use any other solutions with a group of radio, I just use two separate switches.
Can someone point out where I could be mistaken somewhere, since I do not see a lack of logic, any ideas?
In any case, this is the solution I'm trying to implement, but it does not work in the application:
public void onRadioButtonClicked(View view) {
boolean checked = ((RadioButton) view).isChecked();
switch(view.getId()) {
case R.id.radBtnMM:
if (checked)
radioInch.setChecked(false);
break;
case R.id.radBtnInch:
if (checked)
radioMM.setChecked(false);
break;
}
}
source
share