Ole Albers
Ole Albers

Reputation: 9285

include in eclipse for layouts throwing "no resource found"

I am absolutely new to Java and Eclipse. I have two layout-files under /res/layout:

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>

When I try to compile at the "include" - part I get this message:

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

So what is wrong?

Upvotes: 1

Views: 131

Answers (2)

Blundell
Blundell

Reputation: 76458

 @layout/layoutTst

should be the name of the file not its android:id

 @layout/layout_test

Upvotes: 1

Cat
Cat

Reputation: 67502

You need to include the layout filename (layout_test.xml), not the ID of the root in that layout.

<include layout="@layout/layout_test" />

Upvotes: 4

Related Questions