I want to set an initial scrolled position to a ListView.
I thought I could do that by calling list.setSelectionFromTop after adapter.notifyDataSetInvalidated, but of course the later only notifies the listview and the actual population may happen later.
Is there a way be notified when the listview has populated itself, so I can change the scroll?
Ok, so I tried
onFinishInflateandonSizeChanged, but they didn’t work. The later worked if the number if items changed, but not if the data was simply altered.I then tried everything else, and the working methods to override were
onFinishInflateandonSizeChanged. These are however also called on scrolling.In fact, the last line in
ListViewslayoutChildrenis a call toinvokeOnItemScrollListener, so it turns out you don’t have to extendListView, but can simply set anonScrollListener.No matter what solution you choose, you do however need to manually work around the problem of methods being called on scroll.