2013-03-13 82 views

回答

1

我不知道,你正在試圖做什麼,但我認爲你可以把你這樣的單選按鈕之間的意見吧:

<RadioGroup 
     android:id="@+id/RG" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 

      <RadioButton 
       android:id="@+id/RB1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="text1" /> 

      <TextView 
       android:id="@+id/textview" 
       android:text="Place your many other views like this" /> 

      <RadioButton 
       android:id="@+id/RB2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="text2" /> 
     </LinearLayout> 
    </RadioGroup> 
+0

我將其複製到xml文件中。我實際上在屏幕上看不到任何TextView ..我之前就已經這麼做了。所有的意見都沒有了。 – Foenix 2013-03-13 14:15:11

+0

對不起,這是我的錯。我在Radiogroup中編寫了先前的參數android:orientation =「horizo​​ntal」,這就是爲什麼我在活動中看不到任何其他視圖。 – Foenix 2013-03-13 14:40:04

+0

沒問題,很高興你發現錯誤。 – 2013-03-14 08:50:03

2

的一種方式,以單元的單選按鈕被停用您第二個單選按鈕時,拳頭被激活,併爲其他單選按鈕使用相同的OnCheckedChangeListener

這裏基本上是如何做到這一點。

RadioButton1.setOnCheckedChangeListener(new OnCheckedChangeListener(){ 

      public void onCheckedChanged(CompoundButton arg0, boolean arg1) { 
       // TODO Auto-generated method stub 

      RadioButton2.setChecked(false); 

     }); 
+0

謝謝,其實我想現在這個。這是更一般的情況。 – Foenix 2013-03-13 14:41:27