Scrolling with Multiple Listviews for Android

How to scroll many ListViews inside a LinearLayout?

Finally i've found a solution, thanks for all your efforts (^_^), here is a solution : stackoverflow.com/questions/6210895/

How can I allow scrolling of multiple ListViews on a single Activity?

If you use ScrollView, it can be solved.
In your layout.xml file, try to wrap all list views with ScrollView like this.

...
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>

<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
...
</ScrollView>
...

If you can't solve your problem, please check here.

Scrolling with Multiple ListViews for Android

I haven't done this yet, but I've been thinking about it since I'll probably need to do it. I can think of three options: use only one list with the contents of all lists. You can make a ListAdapter that does that and inserts some kind of header. This could probably be something very re-usable.

The other idea is to make a list of lists. But that sounds like asking for trouble.

Multiple ListViews inside a ScrollView

It can be done, although you should not put a listview inside a scrollview but sometimes this is the easier way: https://stackoverflow.com/a/3495908/1117338

Android. Scrolling 2 listviews together

OK. I have an answer now. The problem being that .setSelectionFromTop() would only work if the listview was in the top layout (ie. not nested). Afters some head scratching I realised that I could make my layout a RelativeLayout and get the same look but without having to nest layouts for the checkbox and listview. This is the new layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recordViewLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<CheckBox android:id="@+id/checkBoxTop"
android:text="Check All"
android:layout_width="160dp"
android:layout_height="wrap_content"/>

<ListView android:id="@+id/engNameList"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_below="@+id/checkBoxTop"/>

<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/checkBoxTop">

<LinearLayout android:id="@+id/scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

<include layout="@layout/record_view_line" android:id="@+id/titleLine" />

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

</LinearLayout>

</HorizontalScrollView>

</RelativeLayout>

This basically is the code that goes with the layout.

In onCreate()

engListView=getListView();
engListView.setOnTouchListener(this);

recordListView=(ListView)findViewById(R.id.recordList);
recordListView.setOnScrollListener(this);

and the listener methods:

public boolean onTouch(View arg0, MotionEvent event) {
recordListView.dispatchTouchEvent(event);
return false;
}

public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
View v=view.getChildAt(0);
if(v != null)
engListView.setSelectionFromTop(firstVisibleItem, v.getTop());
}

Display 2 listviews with one being able to scroll

Add the first list contents in some other layout (not ScrollView,ListView) ex.LinearLayout, So you can have only one scrollable list item that is the second one



Related Topics



Leave a reply



Submit