最新版本ButterKnife8.4的使用

1、Library Dependency 搜索添加butterknife 
或  compile 'com.jakewharton:butterknife:8.4.0' 
2、 项目的Gradle文件

dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
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
}

3、 app的Gradle文件

``` apply plugin: 'com.neenbedankt.android-apt'//增加这一句

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.jakewharton:butterknife:8.4.0'//buttetknife
    apt 'com.jakewharton:butterknife-compiler:8.4.0'//添加这一句 } ```

4、使用

  • 需要在 setContentView() 或 inflate() 之后调用bind,申明的所有对象才会创建出来
  • View变量声明的时候不能为private或者static.
  • 除了Activity之外,你可以提供其他的View Root,来获取对象(执行注入).

详细使用方法:http://blog.csdn.net/skeeing/article/details/52386438

5、添加混淆

#ButterKnife
-dontwarn butterknife.internal.**
-keep class **$$ViewInjector { *; }
-keepnames class * { @butterknife.InjectView *;}
-dontwarn butterknife.Views$InjectViewProcessor
-dontwarn com.gc.materialdesign.views.**

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值