Logan Guo
Logan Guo

Reputation: 886

No resource found that matches the given name for Layout_to_left_of

why the layout_toLeftOf attribute could not find the resource. I did have that id in the layout, and why this happens. I am using Intellij IDEA, even I tried to rebuild the code, the error still exists. Any advice, thanks in advance.

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent"
                android:layout_height="@dimen/list_item_entry_container_height"
                android:padding="@dimen/list_item_entry_container_padding">

        <ImageView
                android:id="@+id/list_item_icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"/>

        <ImageView
                android:id="@+id/list_item_space"
                android:layout_width="@dimen/list_item_entry_space_width"
                android:layout_height="fill_parent"
                android:layout_toRightOf="@id/list_item_icon"/>

        <TextView
                android:id="@+id/list_item_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:lines="1"
                android:singleLine="true"
                android:textColor="@color/list_item_entry_title_text_color"
                android:textSize="@dimen/list_item_entry_title_text_size"
                android:layout_toRightOf="@id/list_item_space"
                android:layout_toLeftOf="@id/list_item_action"/>

        <RelativeLayout
                android:id="@+id/list_item_subtitle_group"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@id/list_item_title"
                android:layout_below="@id/list_item_title"
                android:layout_toLeftOf="@id/list_item_action"
                android:layout_toRightOf="@id/list_item_space">
                <ImageView
                        android:id="@+id/list_item_download_status_icon"
                        android:layout_width="@dimen/list_item_entry_download_icon_width"
                        android:layout_height="@dimen/list_item_entry_download_icon_height"
                        android:visibility="gone"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentBottom="true"
                        android:contentDescription="@null"
                        android:layout_marginLeft="@dimen/list_item_entry_download_icon_margin_left"
                        android:layout_marginTop="@dimen/list_item_entry_download_icon_margin_top"
                        android:src="@drawable/list_item_download_ok"/>
                <ProgressBar
                        android:id="@+id/list_item_download_status_progressbar"
                        android:layout_width="@dimen/list_item_entry_download_progressbar_width"
                        android:layout_height="@dimen/list_item_entry_download_progressbar_height"
                        android:layout_alignParentLeft="true"
                        android:layout_marginLeft="@dimen/list_item_entry_download_progressbar_margin_left"
                        android:layout_marginTop="@dimen/list_item_entry_download_progressbar_margin_top"
                        android:layout_toRightOf="@id/list_item_download_status_icon"
                        android:visibility="gone"/>

                <TextView
                        android:id="@+id/list_item_subtitle"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_toRightOf="@id/list_item_download_status_progressbar"
                        android:textColor="@color/list_item_entry_subtitle_text_color"
                        android:textSize="@dimen/list_item_entry_subtitle_text_size"/>
        </RelativeLayout>

        <ImageView
                android:id="@+id/list_item_action"
                android:layout_width="@dimen/list_item_entry_action_width"
                android:layout_height="fill_parent"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"/>

</RelativeLayout>

Upvotes: 1

Views: 354

Answers (2)

Varun Verma
Varun Verma

Reputation: 542

The reason is that list_item_action is defined after it is used. It is defined in the last. It is used before.

As suggested by amit singh - use: @+id => This will define if it is not defined already. Alternatively, move the definition of list_item_action before you use it.

Upvotes: 2

amit singh
amit singh

Reputation: 1422

Replace this line-

android:layout_toLeftOf="@id/list_item_action"

with this line-

android:layout_toLeftOf="@+id/list_item_action"

Upvotes: 2

Related Questions