Tag: Kotlinbutterknife

KotterKnife – 对某些类不能使用bindView(R.id.example_id)

尝试使用KotterKnife时出现以下错误 – 但只适用于某些类。 这是怎么回事? e: /Users/user/dev/git/to14/android/src/main/kotlin/com.example/adapters/ChapterListAdapter.kt: (59, 34): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public fun <T : android.view.View> android.app.Dialog.bindView(id: kotlin.Int): kotlin.properties.ReadOnlyProperty<kotlin.Any, android.widget.TextView> defined in butterknife public fun <T : android.view.View> android.support.v4.app.Fragment.bindView(id: kotlin.Int): kotlin.properties.ReadOnlyProperty<kotlin.Any, android.widget.TextView> defined in butterknife public fun <T : android.view.View> android.app.Fragment.bindView(id: kotlin.Int): kotlin.properties.ReadOnlyProperty<kotlin.Any, android.widget.TextView> […]

lateinit属性尚未初始化

我有一个自定义的linearlayout类,当我想创建这个类的实例,我得到一个错误lateinit属性尚未初始化我正在使用最新版本的butterknife库 这是我的科林类 class MenuItemView : LinearLayout { @BindView(R.id.menu_title_text_view_id) lateinit var menuTitleTextView : CTextBasic constructor(ctx: Context) : super(ctx) { } init { val view = LayoutInflater.from(context).inflate(R.layout.menu_item,this) ButterKnife.bind(this,view) } constructor(ctx: Context, attrs: AttributeSet) : super(ctx, attrs) { val menuAttrs = context.theme.obtainStyledAttributes(attrs, R.styleable.MenuItemView, 0, 0) try { val title: String = menuAttrs.getString(R.styleable.MenuItemView_menu_title) menuTitleTextView.text = title }catch (e : […]

butterknife 7.x和Kotlin M14一起工作吗?

我试图用一些Kotlin代码和Java代码来使用Butterknife。 我知道在M12之前,ButterKnife需要注释处理的支持是不好的或者根本不支持。 所以我把我的活动保持在Java中。 至少在Java中使用Butterknife 6.x和preM12 Kotlin工作。 我现在正在用M13和M14尝试butterknife 7.x。 它应该有注解处理支持,但它不适合我。 bind()函数不会绑定用Java编写的适配器中的任何内容,也不会用Kotlin编写的活动。 我在build.gradle中使用这个(在Github上试过最新版本): apply plugin: 'com.neenbedankt.android-apt' dependencies { provided files('libs/butterknife-annotations.jar') kapt files('libs/butterknife-compiler-8.0.0-SNAPSHOT.jar') compile 'com.jakewharton:butterknife:8.0.0-SNAPSHOT@aar' } 这不会编译。 我也尝试编译“com.neenbedankt.android-apt”,但绑定不起作用。 我知道那里可能还没有支持butterknife 。 但有没有什么破解得到它的工作?

Android:与Butterknife的Kotlin

我正在尝试将Kotlin与Butterknife一起用于我的Android应用程序。 这是我的build.gradle dependencies { … compile 'com.jakewharton:butterknife:8.0.1' kapt 'com.jakewharton:butterknife-compiler:8.0.1' } kapt { generateStubs = true } 我也有一个EditText,我想用ButterKnife在更改时显示一条消息: @OnTextChanged(R.id.input) fun test() { toast(1) } 但是,没有任何反应。 我把一个断点放入函数中 – 甚至没有执行。 PS:我听说过kotterknife,但是我已经看到了纯粹的Butterknife的例子 。 我究竟做错了什么?

事件与kotlin和butterknife处理

将java更改为kotlin代码后,ButterKnife单击注释不起作用。 @OnClick(R.id.btnlogin) internal fun onLogin() { if (isValid) { getLoginAPi() } }