//导入依赖
//布局文件中写控件
com.handmark.pulltorefresh.library.PullToRefreshListView
//查找控件
pull = (PullToRefreshListView) view.findViewById(R.id.pull);
//允许上拉下拉
pull.setMode(PullToRefreshBase.Mode.BOTH);
//设置监听
pull.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2() {
@Override
public void onPullDownToRefresh(PullToRefreshBase pullToRefreshBase) {
list.clear();
page++;
getDataPage(page);
}
@Override
public void onPullUpToRefresh(PullToRefreshBase<ListView> pullToRefreshBase) {
page++;
getDataPage(page);
}
});
//允许返回刷新(在主线程的刷新适配器之后写)
pull.onRefreshComplete();