Android快速生成通用Adapter

来源:互联网 发布:机器学习实战smo算法 编辑:程序博客网 时间:2024/06/17 05:36

转载请注明出处:
http://blog.csdn.net/aa464971/article/details/54755190
Android交流群:146262062
更多开发文章:http://dyhdyh.com

源码与示例apk

https://github.com/dengyuhan/android-adapters

快速开始

Android Studio - 在build.gradle中引入

//必选compile 'com.dyhdyh.adapters:adapters:1.0.0'//如果需要支持DataBinding(可选)compile 'com.dyhdyh.adapters:adapters-databinding:1.0.0'

需要的依赖

compile 'com.android.support:recyclerview-v7:24.2.1'


模板安装

1.下载打包好的templates或者找到源码中的templates文件夹


2.将templates文件夹里的adapters整个复制到AndroidStudio模板目录下

Windows:晚点补充

Mac:/Applications/Android Studio.app/Contents/plugins/android/lib/templates



3.重启Android Studio

快速生成




生成出来的代码

体力活都自动做好了,我们要写的就只有绑定数据了




RecyclerView和ListView的相互转换

当需要将RecyclerAdapter转成ListAdapter的时候,把这两个类名改一下就可以了





更多用法可以看例子工程


Android交流QQ群:146262062
http://dyhdyh.com/
0 0
原创粉丝点击