kotlin使用butternife,不用再找快捷键了
2018-09-03 本文已影响74人
青色石头ing
1.application下build.gradle:
classpath'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath'com.jakewharton:butterknife-gradle-plugin:8.8.1' //添加这一行
application下build.gradle
2.app下build.gradle
applyplugin:'kotlin-android'
applyplugin:'kotlin-android-extensions'
applyplugin:'kotlin-kapt'
build.gradle
dependencies下:
implementation'com.jakewharton:butterknife:8.8.1'
kapt'com.jakewharton:butterknife-compiler:8.8.1'
build.gradle
3.使用
不用generate生成@BindView这些控件了,直接在Butterknife.bind()之后用控件的id直接就能用;
例如 textview的id为tv
直接 tv.setText("kotlin");