版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zsp_android_com/article/details/86219361
XRecyclerView
布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cutOffRule">
<com.jcodecraeer.xrecyclerview.XRecyclerView
android:id="@+id/rvAuditIssue"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none" />
</RelativeLayout>
控件
private XRecyclerView rvAuditIssue;
rvAuditIssue = view.findViewById(R.id.rvAuditIssue);
初始化
// the loading effect we use the AVLoadingIndicatorView
// and it is built in(make a little change)
// we provide all the effect in AVLoadingIndicatorView library besides we add a system style
rvAuditIssue.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader);
rvAuditIssue.setLoadingMoreProgressStyle(ProgressStyle.SquareSpin);
// get default refresh header view
// make refresh time visible, false means hiding
/*rvAuditIssue.getDefaultRefreshHeaderView().setRefreshTimeVisible(true);*/
// if you are not sure that you are 100% going to have no data load back from server anymore, do not use this /*rvAuditIssue.setEmptyView(LayoutInflater.from(getContext()).inflate(R.layout.empty, null));*/
// to control when the item number of the screen is list.size-2, we call the onLoadMore
// default 1
/*rvAuditIssue.setLimitNumberToCallLoadMore(1);*/
// if you don't want the refresh and load more featrue(in that case,you probably dont'n need the lib neither), you can call
rvAuditIssue.setPullRefreshEnabled(false);
监听
rvAuditIssue.setLoadingListener(new XRecyclerView.LoadingListener() {
@Override
public void onRefresh() {
}
@Override
public void onLoadMore() {
pageSize += 1;
new Handler().postDelayed(() -> {
showIssueAudit();
// to notify that the loading more work is done
rvAuditIssue.loadMoreComplete();
}, 1000);
}
});