首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何获得大量的RadioGroup检查无线电按钮?

如何获得大量的RadioGroup检查无线电按钮?
EN

Stack Overflow用户
提问于 2013-11-23 13:22:39
回答 1查看 63关注 0票数 0

我动态地创建了无线电组,每个无线电组都有k个无线电按钮。我想将选中的无线电按钮文本保存到一个文件中,但我不知道如何才能得到每个无线电组检查的无线电按钮id。

我创建了无线电按钮,无线电组如下:

代码语言:javascript
运行
复制
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);

            }

请帮帮我!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-23 13:34:40

迭代所有RadioGroup的循环。

代码语言:javascript
运行
复制
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
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20162834

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档