A little tip for Android radiogroup RadioButton

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.