黄油刀使用方法(butterknife)

来源:互联网 发布:mac os 光盘镜像 编辑:程序博客网 时间:2024/04/28 20:45

使用心得:

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文件是项目还是模块



0 0
原创粉丝点击