一行代码搞定Adapter

时间:2023-03-08 22:03:33
一行代码搞定Adapter

15年Google I/O大会发不了三个重要支持库

>Material design (Android Support Design)

>百分比布局:Percent support lib

>数据绑定: Data Binding Library

如果你还不没用过Data Bind Library 没关系 那你知道ButterKnife吧 DataBindLibrary 和ButterKnife都是编译时期生成相应的注解文件

因此 在性能上不会有什么大的影响 因此放心的尝试吧。(个人感觉DataBind 比ButterKnife 稍微复杂一些 但是用起来也比较爽一些 后面会附上关于

Data Binding使用的一些链接)

一行代码搞定Adapter: 基于 RxJava + Data Binding + RxRecyclerView

new RxDataSource<String>(dataSet).repeat(1).bindRecyclerView
(fragmentBinding.mGridView,R.layout.item_homepage_gridview)
.subscribe(stringViewDataBindingSimpleViewHolder -> { });

详情见 github: https://github.com/ahmedrizwan/RxRecyclerAdapter

关于Data Dinding:

https://www.bignerdranch.com/blog/descent-into-databinding

https://segmentfault.com/a/1190000002876984

https://realm.io/cn/news/data-binding-android-boyar-mount/
https://github.com/LyndonChin/MasteringAndroidDataBinding
https://gold.xitu.io/post/578b944a128fe10063ad6c05

最后附上一张妹子图接着赶路:

一行代码搞定Adapter