Android KotterKnife-无法对某些类使用bindView(R.id.example_id)
我在尝试使用KotterKnife时遇到以下错误-但仅适用于某些类。发生什么事了Android KotterKnife-无法对某些类使用bindView(R.id.example_id),android,kotlin,butterknife,Android,Kotlin,Butterknife,我在尝试使用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:
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> defined in butterknife
public fun <T : android.view.View> android.view.ViewGroup.bindView(id: kotlin.Int): kotlin.properties.ReadOnlyProperty<kotlin.Any, android.widget.TextView> defined in butterknife
public fun <T : android.view.View> android.support.v7.widget.RecyclerView.ViewHolder.bindView(id: kotlin.Int): kotlin.properties.ReadOnlyProperty<kotlin.Any, android.widget.TextView> defined in butterknife
public fun <T : android.view.View> android.app.Activity.bindView(id: kotlin.Int): kotlin.properties.ReadOnlyProperty<kotlin.Any, android.widget.TextView> defined in butterknife
e:/Users/user/dev/git/to14/android/src/main/kotlin/com.example/adapters/ChapterListAdapter.kt:(59,34):未解析引用。由于接收器类型不匹配,以下候选项均不适用:
public fun android.app.Dialog.bindView(id:kotlin.Int):在butterknife中定义的kotlin.properties.ReadOnlyProperty
public-fun-android.support.v4.app.Fragment.bindView(id:kotlin.Int):在butterknife中定义的kotlin.property.ReadOnlyProperty
public-fun-android.app.Fragment.bindView(id:kotlin.Int):在butterknife中定义的kotlin.property.ReadOnlyProperty
public fun android.view.ViewGroup.bindView(id:kotlin.Int):在butterknife中定义的kotlin.properties.ReadOnlyProperty
public fun android.support.v7.widget.RecyclerView.ViewHolder.bindView(id:kotlin.Int):在butterknife中定义的kotlin.properties.ReadOnlyProperty
public fun android.app.Activity.bindView(id:kotlin.Int):在butterknife中定义的kotlin.properties.ReadOnlyProperty
Kotterknife的bindView
委托将仅对活动
、对话框
、视图组
、片段
、支持库片段
和回收器视图的视图持有者
的子类有效。我猜您正在尝试将视图绑定为ListAdapter
的属性,但要使其工作,您必须有一个可以调用findViewById
的对象
对于非回收视图视图持有者
,您可以尝试
class ViewHolder(view: View) {
val textView: TextView = view.findViewById(R.id.name) as TextView
}
扎克,下面的答案有用吗?如果没有,您是否可以添加更多信息,以便我们知道这是否已解决或应该继续寻找答案?