[英]Using the Epoxy ModelView causes Inflate errors and NullPoint errors
[英]Epoxy, Kotlin: Using @ModelView generates nothing with no errors
我可以成功地從此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
}
}
對此進行了多種嘗試以使其正確,但是構建日志中沒有有用的錯誤。
在函數和類上都使用open
而不是abstract
似乎可行。
@ModelView(defaultLayout = R.layout.card_sample)
open class HeaderView : RelativeLayout {
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)
open fun setTitle(string: CharSequence?) {
titleProp = string
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.