我是使用片段的初学者。是否可以有这样的布局:
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<include layout="@layout/waiting_dialog"/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_layout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/bg_tile"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="invisible">
<include layout="@layout/no_entries"/>
</LinearLayout>
</merge>
并在片段的 onCreateView 中使用它,如下所示:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.main, container, false);
return view;
}
总是出现以下错误:
07-11 09:53:47.608: E/AndroidRuntime(5602): android.view.InflateException: \
<merge /> can be used only with a valid ViewGroup root and attachToRoot=true
如何处理这个问题?