1, first on the code
<radiogroup android:layout_width= "match_parent" android:layout_height= "Wrap_content" Android:o rientation= "Horizontal" > <radiobutton android:id= "@+id/rb_feature" Android:layout_widt H= "Match_parent" android:layout_height= "Wrap_content" android:layout_weight= "1" android:b ackground= "@drawable/selector_product_detail_radiobutton" android:button= "@null" android:checked= "tr UE "android:gravity=" center "android:padding=" 8DP "android:text=" Features "and Roid:textcolor= "@color/white"/> <radiobutton android:id= "@+id/rb_description" Android: Layout_width= "Match_parent" android:layout_height= "Wrap_content" android:layout_weight= "1" android:background= "@drawable/selector_product_detail_radiobutton" android:button= "@null" Android: gravity= "Center" android:padding= "8DP" android:text= "Description" android:textcolor= "@color/white"/> </ Radiogroup>
A, if we remove the id attribute of the above radiobutton.
That is, remove android:id= "@+id/rb_feature" and Android:id= "@+id/rb_description", while the first RadioButton set android:checked= "true", then when you
Open this interface, the default will have a RadioButton is selected, but when you click on other RadioButton, the default state of the first selected state of RadioButton will not change, or
Check state. The workaround is not to set the default check state in the XML file, that is, set android:checked= "true" in the code.
b, if we add the id attribute of RadioButton, there will be no problem in a.
A little tip for Android radiogroup RadioButton