I have created RadioGroup
and RadioButton
dynamically as following:
RadioGroup radioGroup = new RadioGroup(context);
RadioGroup radioGroup = new RadioGroup(context);
RadioButton radioBtn1 = new RadioButton(context);
RadioButton radioBtn2 = new RadioButton(context);
RadioButton radioBtn3 = new RadioButton(context);
radioBtn1.setText("Less");
radioBtn2.setText("Normal");
radioBtn3.setText("More");
radioGroup.addView(radioBtn1);
radioGroup.addView(radioBtn2);
radioGroup.addView(radioBtn3);
radioBtn2.setChecked(true);
RadioGroup radioGroup = new RadioGroup(WvActivity.this);
RadioButton radioBtn1 = new RadioButton(this);
RadioButton radioBtn2 = new RadioButton(this);
RadioButton radioBtn3 = new RadioButton(this);
radioBtn1.setText("Less");
radioBtn2.setText("Normal");
radioBtn3.setText("More");
radioGroup.addView(radioBtn1);
radioGroup.addView(radioBtn2);
radioGroup.addView(radioBtn3);
radioGroup.check(radioBtn2.getId());