pulltorefresh框架里面有一个setrefresh()方法,
实现方法:
pullToRefreshListView.setRefreshing(true);
squareHotList = new ArrayList<SquareHot>();
//下面两行代码要通过Handler实现
adapter = new SquareAdapter(getActivity(), squareHotList);
pullToRefreshListView.setAdapter(adapter);
pullToRefreshListView.setOnRefreshListener(new OnRefreshListener2() {
@Override
public void onPullDownToRefresh(PullToRefreshBase refreshView) {
refresh = 0x1;
if (squareHotList!=null&&squareHotList.size() > 1) {
squareHotList.clear();
}
if (Utils.isNetworkAvailable(getActivity())) {
Debuger.log_w(TAG, "excute on PullDown");
initData();
} else {
Utils.showToastShort(getActivity(), "没有网络连接!");
pullToRefreshListView.onRefreshComplete();
}
}
@Override
public void onPullUpToRefresh(PullToRefreshBase refreshView) {
refresh = 0x2;
if (Utils.isNetworkAvailable(getActivity())) {
initData();
} else {
Utils.showToastShort(getActivity(), "没有网络连接!");
pullToRefreshListView.onRefreshComplete();
}
}
});