android 下拉刷新功能,如何在Android中提供列表视图的下拉刷新功能

这不是android设计模式.但是,this出色的库使您可以轻松实现.看一下例子.

希望我能帮上忙.

编辑-2015年12月6日-忽略先前的声明:

现在,这是一种设计模式,Android上的SDK完全支持该模式.

这非常简单,您需要使用SwipeRefreshLayout作为列表(或您可能要刷新的其他数据)的父视图.您可以将任何视图作为子视图放置,它将为该视图创建“拉动刷新”动画.

public class MainActivity extends FragmentActivity implements OnRefreshListener {

private SwipeRefreshLayout _pullToRefreshLayout;

@Override

protected void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.activity_main);

_pullToRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);

_pullToRefreshLayout.setOnRefreshListener(this);

super.onCreate(savedInstanceState);

}

@Override

public void onRefresh() {

//When this is called, your view has a little loader showing to show the user that a network call is in progress

Log.i("SO17065814", "Starting refresh...");

new Handler().postDelayed(new Runnable() {

@Override

public void run() {

mSwipeRefreshLayout.setRefreshing(false); //This stops the refresh animation

Log.i("SO17065814", "Ending refresh...");

}

}, 5000);

}

}