我想用 Epoxy 对我的 recyclerView 使用 kotlin,但是 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
}
}
最佳答案
在 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
关于java - 为什么 Epoxy 不生成模型类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51458230/