2011-01-25 202 views
0

我有一個單選按鈕數組,我從中佈局中動態創建單選按鈕。在這裏,我想要的,當我檢查一個單選按鈕,然後其他單選按鈕應該取消選中。如何操作這個使用單選按鈕數組?請一些身體幫助!android中的單選按鈕

這是圖像。單選按鈕不會自動取消選中。

enter image description here

回答

2

把所有這些RadioButtons內部的RadioGroup

+0

感謝您的幫助!它的工作 –

+0

很高興知道它的工作原理! :-) –

0

是,單選按鈕會自動完成。這裏是供您參考的代碼。希望它可以幫助你。

<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" />