Sunday, November 21, 2010

[android-developers] resetting the ListView after Adapter's data was changed.

I have a list view that can display items based on internal state (it
has items, and 'viewed' items). i need to be able to toggle between by
two states, i do that using a simple button that change the adapter's
state and the adapter then called notifyDatasetChanged().
My data DOES gets updated, however i was facing two problems:
1. if in the previous mode the list was partially scrolled, it stayed
in that state after i changed the data set (if i was half the way down
i'll be half way down in the new data set as well, this is not the
behavior i want, but i cols not find a way to scroll the list manually
to position 0. any ideas ?

2. In my list View each item has an image that is fetched from the
net, as so it's being brought using my networking manager and i send
the image request ONLY if i'm in this screen for the first time OR if
scroll state is idlle, i didn't want to start loading images from the
getView method since if i fling the screen it may load a lot of
unnecessary images. However when calling notifyDatasetChanged() the
scroll listener methods are not called. i solved this one by using
notifyDatasetInvalidated even though my data is not empty, is there a
better way to solve this issue ?

10x!

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate