我在我的应用程序中使用 RefreshableListView 来刷新列表视图,它工作正常,但问题是它在列表末尾返回新项目,但我想返回顶部,请帮忙?
list.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
}
@Override
public void onRefresh(RefreshableListView listView) {
new NewDataTask().execute();// TODO Auto-generated method stub
}
});
private class NewDataTask extends AsyncTask<Void, Void, ArrayList<HashMap<String, String>>> {
@Override
protected ArrayList<HashMap<String, String>> doInBackground(Void... params) {
new_request_feeds("my url"); //method which return json from the url
return fetch;
}
@Override
protected void onPostExecute(ArrayList<HashMap<String, String>> fetch) {
// This should be called after refreshing finished
if(fetch.size()!=0)
{
adapter=new CustomListAdapter(getActivity(), R.id.list_ongoing, fetch);
list.setAdapter(adapter);
}
else
{
System.out.println("no feeds");
Toast.makeText(getActivity(), "no feeds", 3000).show();
}// Here if you wish to do future process for ex. move to another activity do here
list.completeRefreshing();
super.onPostExecute(result);
}
}