1

私は Java と Eclipse の初心者です。/res/layout の下に 2 つのレイアウト ファイルがあります。

activity_main.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>

layout_test.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>

「include」部分でコンパイルしようとすると、次のメッセージが表示されます。

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

そのレイアウトのルートのIDではなく、レイアウトファイル名( layout_test .xml)を含める必要があります。

<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 に答える