Reputation: 12467
I am getting the below error when trying to use KotterKnife - but only for some classes. What's going on?
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
Upvotes: 3
Views: 2254
Reputation: 130
Kotterknife's bindView
delegate will work only on sublclasses of Activity
, Dialog
, ViewGroup
, Fragment
, the support library Fragment
, and recycler view's ViewHolder
. I guess you're trying to bind view as property of ListAdapter
, but to have it work you'll have to have object on which you could call findViewById
.
For non-RecyclerView ViewHolder
you can try
class ViewHolder(view: View) {
val textView: TextView = view.findViewById(R.id.name) as TextView
}
Upvotes: 5