使用心得:
1.Activity ButterKnife.bind(this);必须在setContentView();之后,且父类bind绑定后,子类不需要再bind
2.Fragment ButterKnife.bind(this, mRootView);
3.属性布局不能用private or static 修饰,否则会报错
4.setContentView()不能通过注解实现。(其他的有些注解框架可以)
开源项目:
http://jakewharton.github.io/butterknife/
注解方式 找到控
0。下载插件
1.
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
2.
apply plugin: 'com.neenbedankt.android-apt'
3.
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
使用
鼠标点中布局文件
nice !!!!!!!
使用github上面有详细的介绍,但是要注意gradle文件是项目还是模块