Show multiple ListViews on one screen

I have 2 ListViews and each one gets information from the databse site .... everything is going fine, but I want to show the first list and then the second list below it, without setting a fixed height. For example, the user should scroll to the end of the first list, and then show the second list without showing the scroller. here is what i did:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" > <ListView android:id="@+id/firstlist" android:layout_width="wrap_content" android:layout_height="wrap_content" > </ListView> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <ListView android:id="@+id/secondlist" android:layout_width="wrap_content" android:layout_height="wrap_content" > </ListView> </RelativeLayout> </LinearLayout> 

but the screen does not appear, even if I continue to scroll, only one list appears (first) ... if I do not give them a fixed height, for example android:layout_height="180dp" any ideas?

0
source share
3 answers

I have the same problem before. Here are four solutions:

1.Select android:layout_weight = "1" for each list so that they can halve the screen.

2. Insert them as tabs.

3. List two lists in one list.

4.Use ExpandableListView

0
source

why you are not using ExpandableListView

Example 1

Example 2

Example 3

0
source

Can you try this?

 <?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/listView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" > </ListView> <LinearLayout android:layout_width="match_parent" android:layout_height="5dp" android:background="#C0C0C0" > </LinearLayout> <ListView android:id="@+id/listView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" > </ListView> 

0
source

Source: https://habr.com/ru/post/1480414/


All Articles