I use viewpager with several fragments inside, and most of the fragments consist of a listview. I am going to examine one of them. I tried to work out endless scrolling (since I load data from an external database ) with the method suggested some people:
if(position==getCount()-1){
LoadMore();
}
So everytime the user scrolls down to the momentarily last item, it adds some more item to the listview. Lets say I swipe away and that fragment gets destroyed. Then after a while I go back, what happens now? The fragment has destroyed so the OnCreateView()
method runs again having only the original number of items (10) loaded in the listview now. But the position of the listview is somehow at the very end (at 10), and now anything I do (scroll up and down again) the LoadMore()
function never runs. The listview.getCount()
is 10 again, so there should be no problem. Why is this happening? And why does the above code never runs after swiping back?
Thanks!