tags:

views:

323

answers:

1

Hi,

I have a little problem with a ScrollView.

I have a layout for an activity which is made with a ScrollView. This scrollview contains two ListViews.

<?xml version="1.0" encoding="utf-8"?>

    <ListView android:id="@+id/accountsListView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:scrollbars="none" />

    <ListView android:id="@+id/cardsListView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:scrollbars="none" />

</LinearLayout>

In onCreate method of my activity I compute ListViews height according there contents.

During execution, on activity launch, ScrollView is already scrolled a bit.

So I tried, at the end of onCreate to call method scrollTo(0, 0), but it does not change anything.

Any idea ?

Regards, Quentin

+3  A: 

AHHH!!! Remove ScrollView and leave only ONE ListView in your activity. It's not intended to work this way .If you want to have different content in your ONE listView - modify your adapter, or change the UI But never, ever put different scrollable containers on the same screen/inside each other here is a related post. http://groups.google.com/group/android-developers/browse_thread/thread/e7c8df374fe31733# In theory you can slap two listview on the screen, but expect things to be weird. And i would really redesign it with with either separators or expanders or just with one ListView.

Alex Volovoy
There is a very nice example which you can bend and make really flexby Jeff Sharkeyhttp://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/
Alex Volovoy