Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android error: Error: No resource found that matches the given name

I am new to android, so maybe this question is naive.

I am trying to build a layout with two lists side by side. It works fine when I have one list, but when I add a second one, I get this error.

My view extends Activity and not ListActivity.

But I just can't figure out why my build fails with this error:

\main.xml:13: error: Error: No resource found that matches the given name (at 'id' with value '@android:id/selected_list').
\Android\android-sdk\tools\ant\build.xml:598: The following error occurred while executing this line:
\Android\android-sdk\tools\ant\build.xml:627: null returned: 1

This is what my main.xml looks like:

<ListView  
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:id="@android:id/list"
        android:layout_weight=".5"/>
    <ListView  
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:id="@android:id/selected_list"
        android:layout_weight=".5"/>
like image 524
nunespascal Avatar asked Jun 03 '12 10:06

nunespascal


2 Answers

Use "@+id/list" and "@+id/selected_list" instead of the "@android:id/...".

To find these id's in the code use:

findViewById(R.id.list);

or

findViewById(R.id.selected_list);

and make sure you import the R file: .R; and not com.android.R;

like image 138
marmor Avatar answered Sep 29 '22 06:09

marmor


change your id's of list view

code:

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" >
    </ListView>
    <ListView
        android:id="@+id/selected_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" >
    </ListView>
like image 24
code_finder Avatar answered Sep 29 '22 07:09

code_finder