As noted, the int returned by onCheckedChanged is the id of the button:
public void onCheckedChanged(RadioGroup radioGroup, int i) {
if (radioGroup.getCheckedRadioButtonId() == i){
Log.v(TAG, "Equal" );
}
}
The workaround is quite lame in my opinion, but couldn't come up with better idea.
In the XML layout I define a numeric tag for each button in which order it is, example:
<RadioButton
style="@style/AppRadioButtons"
android:text="@string/p1_rg2_o3"
android:tag="3"/>
<RadioButton
style="@style/AppRadioButtons"
android:text="@string/p1_rg2_o4"
android:tag="4"
/>
Then in the code:
public void onCheckedChanged(RadioGroup radioGroup, int i) {
View v = getView().findViewById(i);
int rbSelection = (int) v.getTag();
dataObject.setPropertySelection(rbselection);
}
}
Seems a waste to call findviewbyid, to get a single int from tag, and this would complicate the code needed for populating the controls from the DB, as each tag would need to be mapped to an id.
but if someone has an idea how to improve this and just get which radio button is clicked by order in the radio group please do so.