1.在工程的build.gradle中添加
'com.jakewharton:butterknife-gradle-plugin:8.5.1'

在app里的 build.gradle中添加
applyplugin:'com.jakewharton.butterknife'
添加依赖
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor'com.jakewharton:butterknife-compiler:8.5.1'
在Activity中的setContentView后初始化
ButterKnife.bind(this);

获取控件

设置单击监听

网友评论