how does scrolling in android listview work?

Posted by gartenkralleb on Stack Overflow See other posts from Stack Overflow or by gartenkralleb
Published on 2010-06-01T13:12:55Z Indexed on 2010/06/01 13:13 UTC
Read the original article Hit count: 923

hi,

i have an android-app with a listview in an activity. the listview has, if i call it so, three data states.

  1. no data loaded from inet -> only one dummy item is visible, saying that data is loading
  2. data is loaded and shown in list
  3. one listitem is clicked and now shows more information for this listitem (so it is increased in its height)

on every state change (1 -> 2, 2 -> 3) i call notifyDataSetChanged() on this ListAdapater. this causes the listview to scroll down to the last item. this is ugly in the first transition and even more ugly in the second because the clicked list item is now out of focus.

as i can see, this happens with a google g1 with android 1.6. a htc touch with the same sdk acts like desired (i try to figure it out with some more devices).

to avoid this i tried to read out getScrollY() and set this value back. but this returns 0. the reason for this return value i already found on stackoverflow in other qutestions.

does anyone else comes along with my problem so far? why does the listview scrolls to the last item? it was mentioned, that listview does keep track on the scroll position. but it seems that it does not in my case. or may i call the wrong refresh method? is notifyDataSetChanged the correct one?

© Stack Overflow or respective owner

Related posts about android

Related posts about android-layout