我想在Kotlin的recyclerView中使用Epoxy,但是Epoxy Model不会生成PostModel_()类,这怎么了?
@EpoxyModelClass(layout = R.layout.iteam)
abstract class PostModel : EpoxyModelWithHolder<PostModel.PostHolder>() {
@EpoxyAttribute
lateinit var userName: String
@EpoxyAttribute
lateinit var avatarIcon: Drawable
@EpoxyAttribute
lateinit var post: Drawable
override fun bind(holder: PostHolder) {
holder.avatarIcon.setImageDrawable(avatarIcon)
holder.post.setImageDrawable(post)
holder.name.text = userName
}
class PostHolder : BaseEpoxyHolder() {
@BindView(R.id.name)
lateinit var name: TextView
@BindView(R.id.ic_avatar)
lateinit var avatarIcon: ImageView
@BindView(R.id.post)
lateinit var post: ImageView
}
}
答案 0 :(得分:3)
在Kotlin中使用Epoxy时,一个常见的错误是混合注释处理引擎。如果您从Epoxy的自述文件中复制了此文件:
dependencies {
implementation 'com.airbnb.android:epoxy:3.x.y'
// Add the annotation processor if you are using Epoxy's annotations (recommended)
annotationProcessor 'com.airbnb.android:epoxy-processor:3.x.y'
}
您可能忘记了在同一自述文件中几行后就没有将他们对kotlin用户的建议应用:
确保使用kapt
代替annotationProcessor