Tag: radio group

如何从不同的LinearLayouts分组RadioButton?

我想知道是否可以将每个单独的RadioButton分组在一个独特的RadioGroup保持相同的结构。 我的结构是这样的: LinearLayout_main LinearLayout_1 RadioButton1 LinearLayout_2 RadioButton2 LinearLayout_3 RadioButton3 正如你所看到的,现在每个RadioButton都是不同的LinearLayout的子LinearLayout 。 我尝试使用下面的结构,但它不工作: radioGroup中 LinearLayout_main LinearLayout_1 RadioButton1 LinearLayout_2 RadioButton2 LinearLayout_3 RadioButton3

如何设置单选button作为Android的radiogroup中的默认值

我已经创build了RadioGroup和RadioButtondynamic如下 RadioGroup radioGroup = new RadioGroup(context); RadioButton radioBtn1 = new RadioButton(context); RadioButton radioBtn2 = new RadioButton(context); RadioButton radioBtn3 = new RadioButton(context); radioBtn1.setText("Less"); radioBtn2.setText("Normal"); radioBtn3.setText("More"); radioBtn2.setChecked(true); radioGroup.addView(radioBtn1); radioGroup.addView(radioBtn2); radioGroup.addView(radioBtn3); 这里一步radioBtn2.setChecked(true); 导致radioBtn2总是被检查。 这意味着我不能通过检查其他两个单选button( radioBtn1 , radioBtn3 )来取消选中radioBtn2 。 我想让RadioGroup只能检查一个单选button(现在可以一次检查两个单选button)。 我怎么解决这个问题?

如何在Android中获取RadioGroup的选定索引

有没有一种简单的方法来获取Android中的RadioGroup选定的索引,或者我必须使用OnCheckedChangeListener来监听更改,并有一些保存最后选定的索引? 例如xml: <RadioGroup android:id="@+id/group1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <RadioButton android:id="@+id/radio1" android:text="option 1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <RadioButton android:id="@+id/radio2" android:text="option 2" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <RadioButton android:id="@+id/radio3" android:text="option 3" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <RadioButton android:id="@+id/radio4" android:text="option 4" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <RadioButton android:id="@+id/radio5" android:text="option 5" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </RadioGroup> 如果用户selectoption 3我想获得索引,2。

RadioGroup有两个有10个RadioButton的列

我有一个RadioGroup ,我想alignmentbutton在两列和五行,我无法实现它。 我已经尝试过的事情: RelativeLayout – > RadioGroup外部 – > RadioGroup内部。 所有RadioButtons被选中,但我只想要select一个。 RadioGroup :方向 跨度,stretchcolumns TableRow TableLayout 请让我知道如何创build一个RadioGroup并有两列和许多RadioButtons内。

如何在Android的RadioButton上设置OnClickListener?

RadioGroup有两个RadioButton 。 我想在这些RadioButton上设置OnClickListener 。 根据单击哪个RadioButtonbutton,我想更改EditText的文本。 我怎样才能做到这一点?