Android error: Error: the resource matching the specified name was not found

I'm 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, I get this error.

My view extends activity, not ListActivity.

But I just can’t understand why my build failed:

\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

Here 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"/>
+5
source share
2 answers

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

To find these identifiers in code, use:

findViewById(R.id.list);

or

findViewById(R.id.selected_list);

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

+10
source

:

    <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>
+3

All Articles