I'm using an AsyncTaskLoader
to load paginated data into an ArrayAdapter
, but when I rotate the device, all of the previously fetched data will be cleared and the top of the list will now start at the last page that I fetched.
private int mPageNumber;
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
int totalItemCount) {
if (mPageNumber >= firstVisibleItem + visibleItemCount) {
mPageNumber++;
getLoaderManager().restartLoader(0, null, this);
}
}
I don't really understand why this happens or the best way to handle it. Should I be caching the data, is that really necessary?