要求
Min SDK version 16
使用说明
在布局中添加PullToRefreshView,加上app:type="soup"属性
<com.yalantis.pulltomakesoup.PullToRefreshView android:id="@+id/pull_to_refresh" app:type="soup" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" android:divider="@null" android:dividerHeight="0dp" android:fadingEdge="none"/> </com.yalantis.pulltomakesoup.PullToRefreshView>
在onCreate方法中找到view并设置OnRefreshListener
mPullToRefreshView = (PullToRefreshView) findViewById(R.id.pull_to_refresh); mPullToRefreshView.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() { @Override public void onRefresh() {} });
要结束刷新调用
mPullToRefreshView.setRefreshing(false);
其他
如果要改变加载状态:
mPullToRefreshView.setRefreshing(boolean isRefreshing)
兼容
- Android JELLY BEAN 4.1+