我正在尝试将一个活动转换为片段,但我在向片段添加扩展视图时遇到了问题。
我需要传递给片段的活动代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.myClassView = new ClassView(this);
layout = new FrameLayout(this);
layout.addView(myClassView);
setContentView(layout);
}
新的片段代码:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle saved)
{
this.myClassView = new ClassView(getActivity());
layout = new FrameLayout(getActivity());
layout.addView(myClassView);
return inflater.inflate(layout, null, false); //ERROR
}
return inflater.inflate(layout, null, false);
我无法做到这一点,因为布局必须是int