1

我对 Java 和 Eclipse 完全陌生。我在 /res/layout 下有两个布局文件:

活动主.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <include layout="@layout/layoutTst" />
</LinearLayout>

布局测试.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/layoutTst"
    android:orientation="vertical" >
</LinearLayout>

当我尝试在“包含”部分进行编译时,我收到以下消息:

Description Resource    Path    Location    Type error: Error: No resource
found that matches the given name (at 'layout' with value
'@layout/layoutTst').   activity_main.xml   /YouSherlock/res/layout line
6   Android AAPT Problem

那么有什么问题呢?

4

2 回答 2

4

您需要包含布局文件名 ( layout_test .xml),而不是该布局中根的 ID。

<include layout="@layout/layout_test" />
于 2012-11-27T22:14:40.920 回答
1
 @layout/layoutTst

应该是文件名而不是它的 android:id

 @layout/layout_test
于 2012-11-27T22:15:04.357 回答