Skip to content

使用databinging库写的关于recyclerView的通用adapter,只需要简单继承,就能够将代码化至最简单!(USES databinging library written about recyclerView universal adapter, only need a simple inheritance, code is changed to the most will be simple!)

License

Notifications You must be signed in to change notification settings

xmtggh/databind_base_recyclerview_adapter

Repository files navigation

##使用 ####step 1

在gradle.build中加入允许使用databing的库

android {

    dataBinding {
        enabled = true
    }
   
}

####step 2

直接在你所需要的adapter中继承AbRecyclerViewDBAdapter,重点来了。。

public class RecAdapter extends AbRecyclerViewDBAdapter<UserBean> {
    public RecAdapter(Context context, List<UserBean> list) {
        super(context, list);
    }

    @Override
    public BindingViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new BindingViewHolder(inflate(R.layout.item_main_rcy,parent));
    }

    @Override
    public void onBindViewHolder(BindingViewHolder holder, int position) {
        holder.getBinding().setVariable(bind.data.com.demo.BR.item, getItem(position));
    }
}


}

使用这个adapter,你只需要加入数据源,在onbindviewholder中绑定view就简简单单了,我还发现利用数据绑定写的RecyclerView的还能解决删除头条数据无法显示动画的问题,欢迎帮忙找bug!第一次分享!希望大家多多支持

About

使用databinging库写的关于recyclerView的通用adapter,只需要简单继承,就能够将代码化至最简单!(USES databinging library written about recyclerView universal adapter, only need a simple inheritance, code is changed to the most will be simple!)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages