I have three radiobuttons in a radiogroup. How can I tell Java to do a different thing depending on which button is selected? I have the group and all of the buttons declared:
final RadioGroup size = (RadioGroup)findViewById(R.id.RGSize);
final RadioButton small = (RadioButton)findViewById(R.id.RBS);
final RadioButton medium = (RadioButton)findViewById(R.id.RBM);
final RadioButton large = (RadioButton)findViewById(R.id.RBL);
I know I would say something like this:
if (size.getCheckedRadioButtonId().equals(small){
} else{
}
But equals is not the correct syntax… How can I ask java which button is selected?
Try: