开发者

Nested listviews

开发者 https://www.devze.com 2023-03-28 22:39 出处:网络
How can i nest listviews? Code : <?xml version=\"1.0\" encoding=\"utf-8\"?> <LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"

How can i nest listviews?

Code :

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

    <ListView
        android:id="@+id/places_listView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">


            <EditText android:id="@+id/places_search_box"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:imeOptions="actionSearch"
            android:singleLine="true"
            android:hint="Search"/>

        </LinearLayout>


        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <ListView
                android:id="@+id/places_listViewP开发者_运维知识库laces"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                >
            </ListView>
        </LinearLayout>
    </ListView>
</LinearLayout>

Where is here the error?

Thanks for help


You don't put items like that in a ListView. You are supposed to use a ListAdapter


You can't nest ListViews, instead implement only one ListView and see the following possibilities :

  • add a header and/or a footer to your ListView.
  • merge your data from different sources into the same adapter via a custom BaseAdapter.
0

精彩评论

暂无评论...
验证码 换一张
取 消