Android RadioGroup checks more than one RadioButton?

前端 未结 3 1320
生来不讨喜
生来不讨喜 2021-01-25 20:44

I am using RadioGroup, added RadioButton rdbut to RadioGroup rdgrp like rdgrp.addView(rdbut).

   for(int j=0         


        
3条回答
  •  一向
    一向 (楼主)
    2021-01-25 20:58

    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]);
             }
        } 
    

提交回复
热议问题