我想:
- 当点击刷新按钮(操作栏)时,我的列表视图将被更新
-
可以在更新任务运行时滚动。
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) {
case R.id.refresh: setRefreshActionButtonState(true); this.startRequest(); ....
return true; } return super.onOptionsItemSelected(item); }
private void startRequest() {
articleList.clear();
articleList.addAll(articleList);
//volley request
...
adapter.notifyDataSetChanged();
}
第一点(更新listview)是ok的,当我点击刷新,但我怎么能解决第二点?
articleList.clear();
articleList.addAll(articleList);
//volley request
...
adapter.notifyDataSetChanged();
只有当你在你的Volley的完整监听器中成功地得到你的响应后才能这样做。在此之前,不要通知适配器或清除数据。