我EpoxyModelWithHolder
在单个 Epoxy 模型类中使用多个布局。如何进行 ViewBinding?目前,我正在使用Kotlin-android-extensions
. 下面是我的代码
@EpoxyModelClass
abstract class ItemSampleEpoxyModel : EpoxyModelWithHolder() {
@EpoxyAttribute
var itemSampleShelf: ComponentFactoryLanderPagesHeroShelf.ComponentLanderPageHeroShelf.ItemLanderPageHeroShelf? =
null
override fun getDefaultLayout() =
when {
itemSampleShelf?.heroStyle == "Project" -> {
R.layout.item_project_sample
}
itemSampleShelf?.shelfItemType == "Course" -> {
R.layout.item_course_sample
}
else -> {
R.layout.item_sample
}
}
override fun bind(itemHolder: ItemSampleEpoxyHolder) {
itemHolder.titleView.text = itemSampleShelf?.title
} }
class ItemSampleEpoxyHolder : EpoxyHolder() {
lateinit var titleView: AppCompatTextView
override fun bindView(itemView: View) {
titleView = itemView.tv_title
}}