我成功地让环氧树脂从此生成代码EpoxyModelClass
@EpoxyModelClass(layout = R.layout.card_sample)
abstract class PhotoModel : EpoxyModelWithHolder<PhotoModel.Holder>() {
@EpoxyAttribute
var title: String? = null
override fun bind(holder: PhotoModel.Holder) {
holder.header.text = title
}
class Holder : EpoxyHolder() {
override fun bindView(itemView: View) {
header = itemView.findViewById(R.id.header_label)
}
lateinit var header: TextView
}
}
但不幸的是不是来自ModelView
. 它构建没有错误,但没有生成围绕此的环氧树脂类:
@ModelView
abstract class HeaderView : LinearLayout {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(
context,
attrs,
defStyle
)
private var titleProp: CharSequence? = null
@TextProp(defaultRes = R.string.app_name)
fun setTitle(title: CharSequence) {
titleProp = title
}
}
尝试了许多变体以使其正确,但构建日志中没有有用的错误。