Java 错误-无法将android.widget.FrameLayout强制转换为android.widget.LinearLayout
我试图添加一个单选按钮(android)到一个视图,但我得到了错误 我的代码-Java 错误-无法将android.widget.FrameLayout强制转换为android.widget.LinearLayout,java,radio,Java,Radio,我试图添加一个单选按钮(android)到一个视图,但我得到了错误 我的代码- public void CreateRadio(HVArrangement layout, String text) { createRadioButton(layout.getView(), text); } private void createRadioButton(View view1, String text) { LinearLayout top = (
public void CreateRadio(HVArrangement layout, String text) {
createRadioButton(layout.getView(), text);
}
private void createRadioButton(View view1, String text) {
LinearLayout top = (LinearLayout) view1;
final RadioButton[] rb = new RadioButton[1];
RadioGroup rg = new RadioGroup(container.$context()); //create the RadioGroup
rg.setOrientation(RadioGroup.HORIZONTAL);//or RadioGroup.VERTICAL
rb[1] = new RadioButton(container.$context());
rb[1].setText(text);
rb[1].setId(1);
rg.addView(rb[1]);
top.addView(rg);//you add the whole RadioGroup to the layout
}
但我得到的错误是,android.widget.FrameLayout不能强制转换为android.widget.LinearLayout
请帮助我您能同时添加布局代码吗?