使用android simpleCursorAdapter的多个列表视图

使用android simpleCursorAdapter的多个列表视图,android,listview,simplecursoradapter,Android,Listview,Simplecursoradapter,我需要使用每个ListView的数据库查询中的数据在一个活动中显示多个ListView,但我无法使用以下代码同时显示两个ListView,是否有人可以确认是否可以以这种方式使用SimpleCursorAdapter,如果可以,我下面的代码有什么问题: 我的XML: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:la

我需要使用每个ListView的数据库查询中的数据在一个活动中显示多个ListView,但我无法使用以下代码同时显示两个ListView,是否有人可以确认是否可以以这种方式使用SimpleCursorAdapter,如果可以,我下面的代码有什么问题:

我的XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
    android:layout_width="fill_parent"
      android:layout_height="wrap_content"
    android:layout_weight="1" >

    <ListView
        android:id="@+id/symptomsList"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:visibility="visible">
    </ListView>
</LinearLayout>


<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1" >

    <ListView
        android:id="@+id/syndromesList"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:visibility="visible">
    </ListView>
</LinearLayout>
看看你的代码

symptomsList.setAdapter(adapter);
symptomsList.setAdapter(adapter2);    // problem here
我想应该是

symptomsList.setAdapter(adapter);
syndromesList.setAdapter(adapter2);

我有一个类似的问题,但当我尝试此修复时,我得到了“RuntimeException:您的内容必须有一个id属性为'android.R.id.list'的ListView”

我的解决办法是制作第一个列表xml,如下所示

<listView
android:id="@+id/android:list"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
</ListView>

第二个listview是这样的xml

<listView
android:id="@+id/android:list2"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
</ListView>

然后在Java代码中


第一个使用setListAdapter,第二个使用setAdapter(myadapter)

一双新鲜的眼睛能做什么,真是太棒了,非常感谢
<listView
android:id="@+id/android:list2"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
</ListView>