Android RadioGroup 检查多个 RadioButton? [英] Android RadioGroup checks more than one RadioButton?
本文介绍了Android RadioGroup 检查多个 RadioButton?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 RadioGroup
,将 RadioButton rdbut
添加到 RadioGroup rdgrp
,如 rdgrp.addView(rdbut)
.
I am using RadioGroup
, added RadioButton rdbut
to RadioGroup rdgrp
like rdgrp.addView(rdbut)
.
for(int j=0;j<3;j++)
{
RadioGroup rdgrp = new RadioGroup;
for(int i=0;i<=10;i++)
{
RadioButton rdbut = new RadioButton(this);
rdbut.setText("RadioButtion"+i);
rdbut.setId(i);
rdbut.setTag("somename");
rdgrp.addView(rdbut);
}
}
上面的代码显示了我如何初始化单选组和单选按钮.在 emulator/mobile 中运行此代码后,我可以一次检查 2 个单选按钮.
the above code shows how I initialize the radiogroup and radio button. after I run the this code, in emulator/mobile , i am able to check 2 radio buttons at a time.
可能是什么问题?
推荐答案
像这样改变你的代码.
RadioGroup rdgrp[] = new RadioGroup[3];
For(int j=0;j<3;j++)
{
RadioButton rdbut[] = new RadioButton[10];
For(int i=0;i<=10;i++)
{
rdbut[i].setText("RadioButtion"+i);
rdbut[i].setId(j*100+i);
rdbut[i].setTag("somename");
rdgrp[j].addView(rdbut[i]);
}
}
这篇关于Android RadioGroup 检查多个 RadioButton?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文