This answer might be late but others those who are facing this issue can try out:
XML:
<?xml version="1.0" encoding="utf-8"?>
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioButton android:id="@+id/radio_pirates"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Iron Man"
android:onClick="buttonClicked"/>
<RadioButton android:id="@+id/radio_ninjas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Batman"
android:onClick="buttonClicked"/>
</RadioGroup>
Activity:
public void buttonClicked(View view) {
// Is the button now checked?
boolean checked = ((RadioButton) view).isChecked();
// Check which radio button was clicked
switch(view.getId()) {
case R.id.iron_man:
if (checked)
// Iron man is the best!
break;
case R.id.batman:
if (checked)
// Batman rocks!
break;
}
}
This is the method that I found on Android Developers page.
radiator.room
returning string resource id or string? – Backman