1.添加依赖:compile 'com.cjj.materialrefeshlayout:library:1.3.0'
2.布局中添加控件,包裹list控件
<com.cjj.MaterialRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.cjj.MaterialRefreshLayout>
3.初始化布局控件
4.设置可上拉加更多:refresh.setLoadMore(true);
5.设置监听回调:refresh.setMaterialRefreshListener(new MaterialRefreshListener() {
a:下拉刷新
public void onRefresh(MaterialRefreshLayout materialRefreshLayout) {}
b:上拉加载更多
public void onRefreshLoadMore(MaterialRefreshLayout materialRefreshLayout) {}