Android错误:错误:找不到与给定名称匹配的资源

nun*_*cal 5 android android-layout

我是android新手,所以也许这个问题很天真.

我正在尝试建立一个并排的两个列表的布局.当我有一个列表时它工作正常,但是当我添加第二个列表时,我收到此错误.

我的视图扩展了Activity而不是ListActivity.

但我无法弄清楚为什么我的构建失败并出现此错误:

\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
Run Code Online (Sandbox Code Playgroud)

这是我的main.xml的样子:

<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"/>
Run Code Online (Sandbox Code Playgroud)

mar*_*mor 10

使用" @+id/list"和" @+id/selected_list"代替" @android:id/...".

要在代码中找到这些id,请使用:

findViewById(R.id.list);
Run Code Online (Sandbox Code Playgroud)

要么

findViewById(R.id.selected_list);
Run Code Online (Sandbox Code Playgroud)

并确保导入R文件:.R; 而不是com.android.R;