1.在项目的project 的build.gredle 文件中的dependencies标签下添加加粗部分。
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.6.0'
}
}
2.在module的build.gredle 文件中的dependencies标签中添加(导入库的依赖)。
[java] view plain copy
compile 'com.jakewharton:butterknife:8.6.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
3.使用将鼠标放在布局文件上如下,alt+insert生成对应的绑定和点击事件,完成。