草庐IT

radioGroup

全部标签

android - 在Android中制作带有图像的RadioGroup单选按钮......如何?

是否可以在Android中制作单选按钮,其中有按钮的图像表示而不是常规按钮?我希望它看起来像这样:中间的青色代表被选中的按钮。我该怎么做? 最佳答案 RadioButton类有buttonDrawable成员,源自CompoundButton.您可以通过多种方式更改此可绘制对象。来自java:myRadioButton.setButtonDrawable(resourceIdorDrawable);来自xml:如果您只是希望选中/未选中状态看起来不同,那么通过右键单击您的res文件夹->新建->添加新的选择器xmlAndroidxm

android - RadioGroup 调用 onCheckChanged() 三次

我一直在努力解决RadioButton的编程检查问题,该RadioButton位于RadioGroup中。似乎单个check()调用会引发三个事件-第一个RadioButton一次,第二个RadioButton两次,这是我的目标。同时点击界面中的第二个RadioButton,只会出现一个事件,没错。那么,有没有办法避免多个事件引发?publicclassRadiogroupActivityextendsActivity{/**Calledwhentheactivityisfirstcreated.*/@OverridepublicvoidonCreate(BundlesavedInst

android - 获取 Android 中 RadioGroup 中的 RadioButtons 数组

有没有办法在AndroidRadioGroup中获取RadioButton的数组(或集合)?我想将单个监听器添加到单选按钮,但我没有看到任何明显的迭代它们的方法。 最佳答案 这应该可以解决问题:intcount=radioGroup.getChildCount();ArrayListlistOfRadioButtons=newArrayList();for(inti=0;i 关于android-获取Android中RadioGroup中的RadioButtons数组,我们在StackOv

android - RadioGroup 有两列有十个 RadioButtons

我有一个RadioGroup,我想在两列五行中将按钮彼此相邻对齐,但我无法实现。我尝试过的事情:RelativeLayout->RadioGroup外部->RadioGroup内部。所有RadioButtons都被选中,但我只想选中一个。RadioGroup:方向跨度、拉伸(stretch)列表格行表格布局请告诉我如何创建一个RadioGroup并在其中包含两列和许多RadioButtons。 最佳答案 您可以模拟该RadioGroup以使其看起来只有一个。例如,您有rg1和rg2(RadioGroups方向设置为vertical(

android - 如何在选中复选框之前禁用 RadioGroup

我有一个单选组,我不希望用户能够选择任何按钮,直到在我的应用程序中选择了一个特定的复选框。如果未选中该复选框,则会禁用radio组。我该怎么做。 最佳答案 真正的诀窍是遍历所有subview(在本例中为:CheckBox)并将其称为setEnabled(boolean)这样的事情应该可以解决问题://initializethecontrolsfinalRadioGrouprg1=(RadioGroup)findViewById(R.id.radioGroup1);CheckBoxck1=(CheckBox)findViewById(

android - RadioGroup.setEnabled(false) 无法按预期工作

我用setEnabled(false)设置为不可用,但是没有用,经过这个方法后,RadioGroup.isEnabled()的值为false.值已更改。代码来自AndroidProgrammingGuide。PS:Spinner组件也使用setEnabled(false)。代码如下:importandroid.app.Activity;importandroid.graphics.Color;importandroid.os.Bundle;importandroid.view.View;importandroid.view.View.OnClickListener;importandr

android - 如何在 ListView 自定义适配器中使用 RadioGroup?

我想在我的列表中显示一个选择选项。我在listView行中使用RadioButton。我知道RadioGroup用于单选。但问题是我在ListRowView中添加了RadioButton。现在我想将我的所有列表项添加到一个RadioButton中。我正在使用CustomAdapter和getView()。我在getView()中得到了RadioButton,但是当想在RadioGroup中添加它时,它说"viewalreadyhaveparent,callremoveView()inparentbefore"而且我知道它是真的,但如果我将它从View中删除。然后就看不到了。我还尝试以编

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

有没有一种简单的方法可以在Android中获取RadioGroup的选定索引,还是我必须使用OnCheckedChangeListener来监听更改并保留最后一个选定索引的内容?示例xml:如果用户选择选项3我要获取索引,2. 最佳答案 你应该可以做这样的事情:intradioButtonID=radioButtonGroup.getCheckedRadioButtonId();ViewradioButton=radioButtonGroup.findViewById(radioButtonID);intidx=radioButto

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

有没有一种简单的方法可以在Android中获取RadioGroup的选定索引,还是我必须使用OnCheckedChangeListener来监听更改并保留最后一个选定索引的内容?示例xml:如果用户选择选项3我要获取索引,2. 最佳答案 你应该可以做这样的事情:intradioButtonID=radioButtonGroup.getCheckedRadioButtonId();ViewradioButton=radioButtonGroup.findViewById(radioButtonID);intidx=radioButto