当我使用视图翻板显示不同的xml并且每个xml包含单选按钮时,我遇到了问题。所以实际上在2种情况下我只需要两种方式来工作。 情况1:
我需要一个2乘2的单选按钮,这意味着在2乘2的位置总共有4个单选按钮,我需要选择其中1个,其他3个未经检查。我的问题是如何在xml中创建我的单选按钮全部在同一组中,虽然不知何故我设法创建一个4单选按钮,它们都不属于同一组。 Any1可以让我知道如何将它们分为1个无线电组?
Codes:
<RadioGroup
android:id="@+id/rg1"
android:layout_height="0dp"
android:layout_width="fill_parent"
android:baselineAligned="false"
android:layout_weight="2.5"
android:orientation="horizontal">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1">
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:checked="true"
android:text="@string/radio1"
android:textColor="#000000"
android:button="@drawable/radiobutton"
android:clickable="true"
android:layout_weight="1"
android:paddingLeft="45dp"/>
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="@string/radio2"
android:textColor="#000000"
android:button="@drawable/radiobutton"
android:clickable="true"
android:layout_weight="1"
android:paddingLeft="45dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1">
<RadioButton
android:id="@+id/radio2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="@string/radio3"
android:textColor="#000000"
android:button="@drawable/radiobutton"
android:clickable="true"
android:layout_weight="1"
android:paddingLeft="45dp"/>
<RadioButton
android:id="@+id/radio3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="@string/radio4"
android:textColor="#000000"
android:button="@drawable/radiobutton"
android:clickable="true"
android:layout_weight="1"
android:paddingLeft="45dp"/>
</LinearLayout>
</RadioGroup>
情况2:
第二种情况是,当我用相同的单选按钮和id翻转到另一个xml时,我尝试使用代码螺母清除单选按钮但它不会工作。
PS:抱歉我的英语不好