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 the
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:
- 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 ? (setSelected is not exactly a solution since i DON’T want any selection i want to stay in touch mode) - 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 ?
regarding #1 it’s my mistake i didn’t read the documentation all the way through apparently, if i’m currently in touch mode no selection will be made, so the job is done by setSelectedPosition().
Regarding #2 i’m still not sure notifyDatasetInvalidated is the solution to make sure onScroll methods will be called.