添加依赖
implementation 'com.github.anzaizai:EasyRefreshLayout:1.3.1'
在RecyclerView外面套一层
<com.ajguan.library.EasyRefreshLayout
android:id="@+id/erl_success_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_success_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.ajguan.library.EasyRefreshLayout>
//将上拉加载更多关闭
mEasyRefreshLayout.setLoadMoreModel(null);
//在这个方法里对两个事件进行处理
mEasyRefreshLayout.addEasyEvent(new EasyRefreshLayout.EasyEvent() {
@Override
public void onLoadMore() {
}
@Override
public void onRefreshing() {
initData();
mEasyRefreshLayout.refreshComplete();
}
});