Dynamic Radio Button Control

后端 未结 3 1006
臣服心动
臣服心动 2020-12-31 11:40

Code ...{

private void createRadioButton() {

        final RadioButton[] rb = new RadioButton[5];
        for(int i=0; i<5; i++){
            rb[i]  = ne         


        
3条回答
  •  一整个雨季
    2020-12-31 12:25

    Your Layout.

        
        
        
    
    

    code

       RadioGroup rg = (RadioGroup) findViewById(R.id.radiogroup);//not this RadioGroup rg = new RadioGroup(this);
     rg.setOrientation(RadioGroup.HORIZONTAL);//or RadioGroup.VERTICAL
        for(int i=0; i<5; i++)
        {
            rb[i]  = new RadioButton(this);
            rg.addView(rb[i]); 
            rb[i].setText("Test");
        }
    

    hope this help you.

提交回复
热议问题