【发布时间】:2013-01-25 16:42:32
【问题描述】:
我有一个Activity 和一个简单的布局。
活动:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_layout);
布局:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.my.layout
android:id="@+id/my_id"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</com.my.layout>
</FrameLayout>
我想用合并标记替换FrameLayout,但结果在setContentView 期间出现以下错误:
01-25 17:08:24.660: E/AndroidRuntime(25837):
java.lang.RuntimeException: Unable to start activity ComponentInfo{my.app/my.app.MyActivity}:
android.view.InflateException: <merge /> can be used only with a valid ViewGroup root and attachToRoot=true
【问题讨论】:
-
我认为问题出在这个
com.my.layout布局上。我可以知道你是如何声明的吗? -
不,不是。您也可以使用 LinearLayout 重现它。
标签: android merge android-framelayout