Views of multiple Android lists that don't scroll independently

I want to create a page with three lists and three headings, but I do not want to scroll them independently, I want the whole page to scroll. Does anyone know how I can achieve this?

Essentially, I want it to look like this:

header
smlheader
list
smlheader
list
smlheader
list

With this code, I tried to achieve it, but it is not.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"

<TableLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/white">

   <include layout="@layout/header" />
   <include layout="@layout/redcell" />

   <TableRow

       android:id="@+id/tableRow1"
       android:layout_width="wrap_content"
       android:layout_height="60dp" >


      <TextView

        android:id="@+id/fixtures_text"
        android:layout_width="match_parent"
        android:layout_height="60dp"

        android:gravity="center"
        android:text="@string/leagues"
        android:textColor="@color/white"
        android:textSize="25dp"
        android:textStyle="bold"/>




   </TableRow>

   <include layout="@layout/redcell" />

   <TableRow
       android:id="@+id/tableRow2"
       android:layout_width="wrap_content"
       android:layout_height="60dp" >


      <TextView

        android:id="@+id/results_text"
        android:layout_width="match_parent"
        android:layout_height="60dp"

        android:gravity="center"
        android:text="@string/leagues"
        android:textColor="@color/white"
        android:textSize="25dp"
        android:textStyle="bold"/>

   </TableRow>

    <include layout="@layout/redcell" />


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

</TableLayout>
<ScrollView/>
+5
source share
1 answer

I would try CommonsWare MergeAdapter as pointed out by Rajesh. This is similar to what you need.

Take several types (including lists) and connect them together, then you install the merge adapter in listview and presto, you have several lists in one.

Quote from the docs for him:

MergeAdapter ListView, . , , ..

MergeAdapter addAdapter(), addView() addViews() ( ), ListView.

1) .jar
2) .jar CWAC SackOfViewsAdapter, MergeAdapter.
2) "libs" ( , src res)
3) .jar (Eclipse , )
4) MergeAdapter .

:

myMergeAdapter = new MergeAdapter();
myMergeAdapter.addView(HeaderView);
myMergeAdapter.addView(SmallHeaderView1);
myMergeAdapter.addAdapter(listAdapter1);
myMergeAdapter.addView(SmallHeaderView2);
myMergeAdapter.addAdapter(listAdapter2);
myMergeAdapter.addView(SmallHeaderView3);
myMergeAdapter.addAdapter(listAdapter3);

setListAdapter(myMergeAdapter);

2

, :

View Header = getLayoutInflater.inflate(R.layout.red_cell);
myMergeAdapter.addView(Header);
+13

All Articles