一、优势:
1.1,提供上拉刷新与下拉加载的封装;
1.2,提供Head布局;
1.3,提供一个SmartRecycleView多种布局、多种Grid布局、Grid不规则布局。
二、SmartRecycleView的使用
2.1,引入SmartRecycleView,可选择依赖第三方或者配置远程仓库
Gradle Dependency Add this in your root build.gradle
file (not your module build.gradle
file):
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
2.2,xml中引入
<me.zuichu.recyclerview.view.SmartRecyclerview
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
2.3,Activity中设置布局管理器
//设置布局管理器
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerview.setLayoutManager(linearLayoutManager);
2.4,Activity中设置Adapter
//设置Adapter
mainAdapter = new MainAdapter(this, list);
recyclerview.setAdapter(mainAdapter);
2.5,Activity中设置监听事件
//设置监听事件
mainAdapter.setOnItemClickListener(this);
mainAdapter.setOnItemLongClickListener(this);
recyclerview.setLoadingListener(this);
2.6,Activity中实现SmartRecycleView提供的接口
implements SmartRecyclerview.LoadingListener,BaseSmartAdapter.OnRecyclerViewItemClickListener, BaseSmartAdapter.OnRecyclerViewItemLongClickListener
2.7,SmartRecycleView提供了对外方法
//SmartRecycleView对外提供的方法
recyclerview.refresh(); //刷新完成,要使用
recyclerview.loadMoreComplete(); //加载更多完成,要使用
recyclerview.setNoMore(true); //没有更多数据了,要使用
recyclerview.setRefreshProgressStyle(ProgressStyle.BallBeat); //可以自己设置更改刷新和加载更多的样式
recyclerview.setLoadingMoreProgressStyle(ProgressStyle.BallClipRotate);
recyclerview.setArrowImageView(R.mipmap.ic_pulltorefresh_arrow); //可以自己设置更改刷新的箭头,不设置的话为默认
2.8,其中Adapter根据需要,这里选择继承
BaseSmartAdapter<String>
class MainAdapter extends BaseSmartAdapter<String> {
public MainAdapter(Context context, List<String> lists) {
super(context,R.layout.item_main, lists);
}
@Override
public void bindData(SmarViewHolder smarViewHolder, String s) {
}
}
参考地址:https://github.com/zuichu/SmartRecyclerView
猛戳这里下载demo