我在尝试使用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 butterknifepublic fun <T : androID.vIEw.VIEw> androID.support.v4.app.Fragment.bindVIEw(ID: kotlin.Int): kotlin.propertIEs.ReadonlyProperty<kotlin.Any, androID.Widget.TextVIEw> defined in butterknifepublic fun <T : androID.vIEw.VIEw> androID.app.Fragment.bindVIEw(ID: kotlin.Int): kotlin.propertIEs.ReadonlyProperty<kotlin.Any, androID.Widget.TextVIEw> defined in butterknifepublic fun <T : androID.vIEw.VIEw> androID.vIEw.VIEwGroup.bindVIEw(ID: kotlin.Int): kotlin.propertIEs.ReadonlyProperty<kotlin.Any, androID.Widget.TextVIEw> defined in butterknifepublic 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 butterknifepublic fun <T : androID.vIEw.VIEw> androID.app.Activity.bindVIEw(ID: kotlin.Int): kotlin.propertIEs.ReadonlyProperty<kotlin.Any, androID.Widget.TextVIEw> defined in butterknife
解决方法:
Kotterknife的bindVIEw委托仅适用于Activity,Dialog,VIEwGroup,Fragment,支持库Fragment和recycler视图的VIEwHolder的子类.我猜你试图将视图绑定为listadapter的属性,但是为了使它工作,你必须有一个可以调用findVIEwByID的对象.
对于非RecyclerVIEw VIEwHolder,您可以尝试
class VIEwHolder(vIEw: VIEw) { val textVIEw: TextVIEw = vIEw.findVIEwByID(R.ID.name) as TextVIEw }
总结 以上是内存溢出为你收集整理的android – KotterKnife – 不能对某些类使用bindView(R.id.example_id)全部内容,希望文章能够帮你解决android – KotterKnife – 不能对某些类使用bindView(R.id.example_id)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)