在Kotlin下使用ButterKnife框架
来源:互联网 发布:黄金时代知乎 编辑:程序博客网 时间:2024/05/18 02:57
Android jar 包
compile 'com.jakewharton:butterknife:8.0.1'apt 'com.jakewharton:butterknife-compiler:8.0.1'
代码
@BindView(R.id.tv_regist_trade)TextView tv_regist_trade;@BindView(R.id.ll_trade_all)LinearLayout llTrade;
View mContextView;
@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);mContextView = LayoutInflater.from(this).inflate(R.layout.activity_main, null);setContentView(mContextView);//初始化控件
}ButterKnife.bind(this);
@Overrideprotected void onDestroy() { //接触绑定 ButterKnife.bind(this, mContextView).unbind(); super.onDestroy();}
kotlin jar 包
compile 'com.jakewharton:kotterknife:0.1.0-SNAPSHOT'
repositories { maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
代码val tv_regist_trade: TextView by bindView<TextView>(R.id.tv_regist_trade)val llTrade: LinearLayout by bindView<LinearLayout>(R.id.ll_trade_all)/**当前Activity渲染的视图View**/var mContextView: View? = null
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mContextView = LayoutInflater.from(this).inflate(R.layout.activity_main, null) super.setContentView(mContextView)}
阅读全文
1 0
- 在Kotlin下使用ButterKnife框架
- 在Kotlin的语言环境下使用ButterKnife框架
- Kotlin环境下使用如何butterKnife
- Android Studio 如何在 Kotlin 中使用 ButterKnife
- Kotlin框架--配置及ButterKnife无效问题
- ButterKnife注解框架使用
- ButterKnife框架使用详解
- butterknife框架的使用
- Butterknife懒人框架使用
- ButterKnife框架使用详解
- ButterKnife框架使用
- ButterKnife框架使用详解
- Android ----- butterknife框架使用
- ButterKnife框架使用详解
- ButterKnife框架的使用
- 一脸懵逼之Kotlin使用ButterKnife无效问题
- Butterknife 注解框架在 Android Studio 上的使用
- 注解框架最新butterknife在Androidstudio中的使用
- 第八章 拦截器机制
- 超简单CentOS7 配置阿里云yum源
- 亚马逊EC2建立虚拟机并使用ssh连接
- JS延时函数,格1秒触发
- 人们常用的HTML5前端开发框架有哪些
- 在Kotlin下使用ButterKnife框架
- Tocmat-logger4j.properties和log4j.xml的区别
- 详解NTFS文件系统
- 最常用的20个正则表达式,亲测可用!
- 人工智能-一种现代的方法 全文总览
- oracle数据库下导出、导入某个用户下的所有相关信息,包括表、存储过程和视图
- 请分析此例子为什么会出现死锁?
- Fragment全面解析
- 靠脸吃饭变热点_你看好人脸识别技术吗?