Android butterknife 的简单使用

gitup地址:https://github.com/JakeWharton/butterknife

介绍文章:https://blog.csdn.net/qq_29924041/article/details/80538360

 

一、导入

implementation 'com.jakewharton:butterknife:10.2.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0'

同时在上面的android中加上
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
二、安装插件

在File->Setting->Plugins中输入butterknife添加插件,然后重启AndroidStudio

三、在activity使用

先定义布局文件

 

 

 

activity:
在R.layout.activity_main中 alt+insert

 

 

 四、在fragment中使用

布局与activity 中基本一样

但是要加几个步骤

1、实例化

private Unbinder unbinder;

2、在onCreateView()方法进行绑定

 

 3、最后记得在onDestroyView()方法中进行解绑

 

 

 





 




转载于:https://www.cnblogs.com/guochangxin/p/11556150.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值