https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh
xml文件 包裹需要刷新到控件
<in.srain.cube.views.ptr.PtrClassicFrameLayout android:id="@+id/refresh" android:layout_height="0dp" android:layout_width="match_parent" android:layout_weight="12" cube_ptr:ptr_duration_to_close="200" cube_ptr:ptr_duration_to_close_header="1000" cube_ptr:ptr_keep_header_when_refresh="true" cube_ptr:ptr_pull_to_fresh="false" cube_ptr:ptr_ratio_of_header_height_to_refresh="1.2" cube_ptr:ptr_resistance="1.7" >
java
refresh.setLastUpdateTimeRelateObject(this); //显示时间信息 refresh.setPtrHandler(new PtrDefaultHandler() { //下拉刷新时触发方法 @Override public void onRefreshBegin(PtrFrameLayout frame) { getNetListData(); isRefresh = true; } }); //设置进入页面自动刷新 refresh.post(new Runnable() { @Override public void run() { refresh.autoRefresh(); } });refresh.refreshComplete(); //自动刷新结束
自定义下拉刷新头 需要java代码中多添加 头
//创建刷新头 HandView handView = new HandView(getActivity()); // MaterialHeader pullRoRefreshHeadView = new MaterialHeader(getActivity()); //添加头 refresh.setHeaderView(handView); //添加属性头控件 refresh.addPtrUIHandler(handView);