I have used the following code snippet to set one radio button to unchecked if the other is selected,but when I run the application and select both radio buttons the code doesn't work as both stay selected.
I'm using a relative layout so I can't use any other solutions with a radio group,I'm just using two seperate radio buttons.
Can someone point out where I could be going wrong somewhere as I can't see a flaw in the logic,any ideas?
Anyways this is the solution I'm trying to implement but its not working in application:
public void onRadioButtonClicked(View view) {
// Is the button now checked?
boolean checked = ((RadioButton) view).isChecked();
// Check which radio button was clicked
switch(view.getId()) {
case R.id.radBtnMM:
if (checked)
//set inch button to unchecked
radioInch.setChecked(false);
break;
case R.id.radBtnInch:
if (checked)
//set MM button to unchecked
radioMM.setChecked(false);
break;
}
}
this
:The method setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener) in the type CompoundButton is not applicable for the arguments (MainActivity)
– Salmonella