I’m so close here and I’ve tried many things but cannot get it to work. I have two listviews here. What I want is for each listview to show its ENTIRE content. I don’t want the listviews scrollable. I want the Scrollview that holds the listviews scrollable. The closest i’ve been able to get it (which is wrong) is so that each listview is scrollable. This means that each listview only shows like 1 1/2 cells. I would think this would be a dirt simple task but Android has some quirky things going on.
So again, each list view shows its entire content, even if that content height goes past the screen. Then all I have to do is scroll down to see the second list view which shows its entire content.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:orientation="vertical"
android:fillViewport="true">
<LinearLayout
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:orientation="vertical"
android:fillViewport="true">
<LinearLayout
android:layout_weight="10"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CCCCCC"
android:text="@string/alerts_top_title"
android:gravity="center"
android:textColor="#000000"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
</TextView>
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/cameraListAlerts" >
</ListView>
</LinearLayout>
<LinearLayout
android:layout_weight="10"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TextView
android:gravity="center"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CCCCCC"
android:textColor="#000000"
android:text="@string/alerts_bottom_title">
</TextView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="8dp">
</LinearLayout>
<Button
android:id="@+id/addRecipient"
android:layout_height="50dp"
android:layout_width="fill_parent"
android:layout_centerHorizontal="true"
android:text="@string/addRecipient"/>
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/recipientListAlerts" >
</ListView>
</LinearLayout>
</LinearLayout>
</ScrollView>
You’re going to spend far more time and energy trying to get this to work if it ever does.
ListViews exist to handle long lists that require too many resources to be drawn at one time. They recycle the row Views when you scroll through them to allow for a snappy load. You’re trying to ditch that functionality, thereby making your use of theListViewessentially pointless.Populating a
LinearLayoutprogrammatically is no big deal at all. Do you have an XML file for your rows? Inflate it for each new row as you run an extremely simpleforloop through your Array orwhileloop through your Cursor, binding the data, and adding it to yourLinearLayout.Done. No scrolling issues… it’s all handled by the ScrollView like it should be.