Java XML列表视图问题

Java XML列表视图问题,java,android,Java,Android,正在尝试使用数据库查询的结果设置listview 无论如何,我的listview中出现了一个奇怪的XML引用id错误。有人能看到这里的问题吗?我猜是“@id”引用导致了这个问题 以下是我的XML: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pa

正在尝试使用数据库查询的结果设置listview

无论如何,我的listview中出现了一个奇怪的XML引用id错误。有人能看到这里的问题吗?我猜是“@id”引用导致了这个问题

以下是我的XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ListView
    android:id="@+id/contentList"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
</ListView>

</LinearLayout>

我觉得这个不错。您可以将
更改为
/>
,稍微清理一下xml。请尝试清理项目,以确保R文件得到更新。有日志可以发布吗?错误到底是什么?

您丢失了很多相关信息(堆栈跟踪、调用findViewById的位置、调用的类、为什么使用
id.contactList
而不是
id.contentList
),但我猜您没有设置活动的内容视图。嗨,詹姆斯。我已经洗过好几次了。实际错误在“contentList”引用中,错误描述为“布局无法解析,或不是字段”。请确保您正在从包中导入
R.java
文件,而不是像android这样的其他包。您能否调查您的R文件并检查是否在其中定义了
联系人列表
ListView listContent = (ListView)findViewById(R.id.contentList);