您的位置:首页 > 移动开发 > Android开发

android(android studio)中使用注解框架butterknife

2016-01-16 15:34 666 查看
使用butterknife的原因是 当一个布局文件中组件太多的时候 就需要我们去写很多重复的代码 所以butterknife能够帮助我们减少一定的(无用的)代码量

1.android studio安装插件

首先点击File ->setting ->plugins



然后再新的对话框搜索butterknife 我这个是已经安装 点击install 会重启android Studio 然后就可以使用了


2.添加依赖

在build.gradle 添加依赖

compile 'com.jakewharton:butterknife:7.0.0' 





3.使用

在需要写findViewById()这样的activity或者fragment中 对着R.layout.xxx右键 点击 generate 会有butterknife 点击 就出现了 然后修改自己想要的名称就行

相关链接:

butterknife Github地址 http://jakewharton.github.io/butterknife/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: