多功能列表适配器
代码地址:https://github.com/BitToNet/FeloneHelper/blob/master/README.md#多功能列表适配器
功能非常强大的帮助类 ,原作者地址BRVAH
这里对帮助类做了封装,加了很多功能,使得recycleview的使用变得非常方便灵活
所有项目中都设计到了recycleview的内容都是通过他实现的,比如照片选择器,通讯录
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
api "com.android.support:recyclerview-v7:28.0.0"
// adapter适配
api 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.38'
// 图片选择库,包含gradle
api 'com.github.LuckSiege.PictureSelector:picture_library:v2.2.3'
// 评分控件
api 'me.zhanghai.android.materialratingbar:library:1.3.1'
}
拷贝基类
主要是这个,然后根据需要他拷其他资源
holder/BaseViewHolderHelper
几行代码就可以搞定
private List<Bean> mDateList;
private LinearLayoutManager manager;
private YouAdapter mAdapter;
manager = new LinearLayoutManager(this);
manager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(manager);
mAdapter = new YouAdapter(mDateList);
mRecyclerView.setAdapter(mAdapter);
YouAdapter定制适配器
//1.把k换为数据的bean类
//2.加list布局R.layout.item
//3.用helper给每个条目的控件设置资源
public class YouAdapter extends BaseQuickAdapter<K, BaseViewHolderHelper> {
public YouAdapter(@Nullable List<K> data) {
super(R.layout.item, data);
}
@Override
protected void convert(BaseViewHolderHelper helper, K item) {
helper.setText(R.id.tvName, item.getName());
helper.setImageUrl(R.id.iv_icon, item.getImageUrl(), R.drawable.);
}
}