【发布时间】:2013-03-15 07:06:17
【问题描述】:
我在我的安卓应用中使用PullToRefresh。到目前为止它工作正常。
我面临的问题是,当我从 TOP 新行下载“发布以刷新”上的新 x 行时,新行会推送现有行并从 0 位置开始,这对用户来说很烦人。我想要的是,下载新的行列表后应该保留在那里,让用户向下查看新的行集。
知道如何实现这一目标吗?
【问题讨论】:
标签: android android-listview pull-to-refresh
我在我的安卓应用中使用PullToRefresh。到目前为止它工作正常。
我面临的问题是,当我从 TOP 新行下载“发布以刷新”上的新 x 行时,新行会推送现有行并从 0 位置开始,这对用户来说很烦人。我想要的是,下载新的行列表后应该保留在那里,让用户向下查看新的行集。
知道如何实现这一目标吗?
【问题讨论】:
标签: android android-listview pull-to-refresh
这是我用的
//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);
}
});
也检查一下: Maintain/Save/Restore scroll position when returning to a ListView
【讨论】: