我有一個單選按鈕數組,我從中佈局中動態創建單選按鈕。在這裏,我想要的,當我檢查一個單選按鈕,然後其他單選按鈕應該取消選中。如何操作這個使用單選按鈕數組?請一些身體幫助!android中的單選按鈕
這是圖像。單選按鈕不會自動取消選中。
我有一個單選按鈕數組,我從中佈局中動態創建單選按鈕。在這裏,我想要的,當我檢查一個單選按鈕,然後其他單選按鈕應該取消選中。如何操作這個使用單選按鈕數組?請一些身體幫助!android中的單選按鈕
這是圖像。單選按鈕不會自動取消選中。
把所有這些RadioButtons內部的RadioGroup
單選按鈕做到這一點automatycally但你必須給他們組在RadioGroup中: http://developer.android.com/intl/es/reference/android/widget/RadioGroup.html
是,單選按鈕會自動完成。這裏是供您參考的代碼。希望它可以幫助你。
<RadioButton android:id="@+id/radio_red"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Red" />
<RadioButton android:id="@+id/radio_blue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Blue" />
感謝您的幫助!它的工作 –
很高興知道它的工作原理! :-) –