Retaining scroll position on Pull To Refresh
android, android-listview, pull-to-refresh
Solution
This is what i use
//Get old position before updating adapter
final int old_pos = mListView.getRefreshableView().getFirstVisiblePosition()+1;
//Set Adapter
mListView.setAdapter(mListAdapter);
//Set the list to old postion
//mListView.getRefreshableView().setSelection(old_pos);
mListAdapter.notifyDataSetChanged();
mListView.onRefreshComplete();
mListView.post(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
mListView.getRefreshableView().setSelection(old_pos);
}
});
also check this: Maintain/Save/Restore scroll position when returning to a ListView
Problem
I am using PullToRefresh in my android app. It is working fine so far. Issue I am facing is when I download new x rows on "Release to refresh" from TOP new rows pushes existing rows and starts from 0 position it is annoying for the user. What I want is, after downloading new set of rows list should remain there and let user fling down to view new set of rows. any idea how can I achieve this?