在Android中拉动ListView时刷新适配器

时间:2012-10-19 12:15:06

标签: android android-layout listview pull-to-refresh

如何应用下拉ListView的效果并释放它,它会刷新。 与Facebook相同,当它下拉时,它将刷新NewsFeeds。

2 个答案:

答案 0 :(得分:2)

访问此链接。它有一个工作演示或拉动刷新列表视图:

Pull To Refresh Demo

Refreshable List View

答案 1 :(得分:2)

您可以使用this在Android中创建此类列表。

您必须在代码中使用刷新侦听器:

   PullToRefreshListView listView = (PullToRefreshListView) findViewById(R.id.pull_to_refresh_listview);
   listView.setOnRefreshListener(new OnRefreshListener() {


public void onRefresh() {
    // Your code to refresh the list contents

    // ...

    // Make sure you call listView.onRefreshComplete()
    // when the loading is done. This can be done from here or any
    // other place, like on a broadcast receive from your loading
    // service or the onPostExecute of your AsyncTask.

    listView.onRefreshComplete();
}
});