[英]How to get a lot of RadioGroup checked radiobuttons?
I created dynamically, n radiogroup, and every radiogroup have k radiobutton. 我动态创建了n个单选按钮组,每个单选按钮组都有k个单选按钮。 I would like to save the checked radiobuttons text to a file, but i dont know how can i get every radiogroup checked radiobutton id.
我想将选中的单选按钮文本保存到文件中,但是我不知道如何获取每个选中的单选按钮id。
I create the radiobutton, and radiogroup like this: 我创建了单选按钮和单选组,如下所示:
if (Integer.parseInt(cells[1])==1){
rg = new RadioGroup(this);
for (int i=2;i<cells.length;i++){
rb = new RadioButton(this);
rb.setText(cells[i]);
rb.setId(i);
rg.addView(rb);
}
lin.addView(rg);
}
Please help me! 请帮我!
Iterate the loop of all the RadioGroup 's 迭代所有RadioGroup的循环
for (int i = 0; i < particularRadioGroup.getChildCount(); i++) {
RadioButton childAt = (RadioButton) particularRadioGroup.getChildAt(i);
boolean checked = childAt.isChecked();
int id = childAt.getId();
String text = childAt.getText().toString();
// Save the Data of the RadioButton of the Particluar RadioGroup
// Save Here
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.