1.引用:
compile 'in.srain.cube:ultra-ptr:1.0.10'
2..xml定义
<in.srain.cube.views.ptr.PtrClassicFrameLayout android:id="@+id/swipe_container" xmlns:cube_ptr="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/cube_mints_f1f1f1" 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"> 3.使用 (1)(3)方法的实现implements PtrHandler(2)使用layoutManager = new LinearLayoutManager(getActivity());swipe_container.setPtrHandler(this); // header final StoreHouseHeader header = new StoreHouseHeader(getActivity()); header.setPadding(0, LocalDisplay.dp2px(15), 0, 0); header.setTextColor(getResources().getColor(R.color.maincolor)); header.initWithString("bamasoso"); swipe_container.setDurationToCloseHeader(3000); swipe_container.setHeaderView(header); swipe_container.addPtrUIHandler(header);
@Override public boolean checkCanDoRefresh(PtrFrameLayout ptrFrameLayout, View view, View view1) { return layoutManager.findFirstCompletelyVisibleItemPosition() == 0; } @Override public void onRefreshBegin(PtrFrameLayout ptrFrameLayout) { getDatas(); }