Android的RadioGroup中检查不止一个单选按钮? [英] Android RadioGroup checks more than one RadioButton?

查看:126
本文介绍了Android的RadioGroup中检查不止一个单选按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 RadioGroup中,加入单选rdbut RadioGroup中rdgrp 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);
         }
    }    

以上code显示了如何初始化RadioGroup中和单选按钮。我运行这个code后,在仿真器/手机,我能够检查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.

这可能是什么问题?

推荐答案

更​​改code这样的。

Change your code like this.

  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中检查不止一个单选按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆