我试图动态地实现无线电天线的无线电组,但是无法正确实现,我已经在这个网站上尝试了一些方法,但由于我的代码有点不同,它们无法正常工作。我的radiobutton和radiogroup代码。请帮我处理我的代码。谢谢
public class XmlGuiRadio extends LinearLayout {
TextView label,labelOS;
RadioGroup rg;
RadioButton radio;
public XmlGuiRadio(Context context, String labelText, String initialText) {
super(context);
labelOS = new TextView(context);
labelOS.setText("Preferred OS: ");
labelOS.setTextColor(Color.parseColor("#000000"));
rg = new RadioGroup(context);
//rg.setOrientation(RadioGroup.HORIZONTAL);
//rg.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.MATCH_PARENT));
radio = new RadioButton(context);
radio.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
radio.setHint("-> " + labelText);
radio.setHintTextColor(Color.parseColor("#000000"));
radio.setTextColor(Color.parseColor("#000000"));
radio.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f);
//this.addView(label);
this.addView(rg);
this.addView(labelOS);
this.addView(radio);
}