您好,我在使用 Android 2.3.3 时遇到此异常:
android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
此方法中引发异常:(创建片段时)
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (container == null) {
// We have different layouts, and in one of them this
// fragment's containing frame doesn't exist. The fragment
// may still be created from its saved state, but there is
// no reason to try to create its view hierarchy because it
// won't be displayed. Note this is not needed -- we could
// just run the code below, where we would create and return
// the view hierarchy; it would just never be used.
return null;
}
try {
//exception here
theLayout = (LinearLayout) inflater.inflate(R.layout.fragment1, container, false);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return theLayout;
}
当我转到 Activity 并再次返回 FragmentActivity 并切换选项卡时会发生这种情况。
我应该为此做些什么?
谢谢。