XML
<RadioGroup
android:id="@+id/radio1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioButton
android:id="@+id/radPa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Laki-laki"
android:checked="true" />
<RadioButton
android:id="@+id/radPi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Perempuan" />
</RadioGroup>
JAVA
RadioGroup st;
RadioButton radPa,radPi;
rg = (RadioGroup) findViewById(R.id.radio1);
radPa= (RadioButton) findViewById(R.id.radPa);
radPi= (RadioButton) findViewById(R.id.radPi);
String JK=myJSON.getString(TAG_jenis_kelamin);
if(JK.equalsIgnoreCase("Perempuan")){
((RadioButton)rg.getChildAt(1)).setChecked(true);
}
else{//Laki-laki ((RadioButton)st.getChildAt(0)).setChecked(true);
}
String ljenis_kelamin="Laki-Laki";
if(radPi.isChecked()){ljenis_kelamin="Perempuan";}