-
-
Notifications
You must be signed in to change notification settings - Fork 58
DataBinding
angcyo edited this page Jul 14, 2021
·
1 revision
请依赖对应的-binding
版本后缀名的版本, 否则将不支持DataBinding
.
之后使用com.angcyo.dsladapter.DslViewHolder#binding
获取binding
对象,其他无变化.
demo代码:
class DslBindingTextItem : DslAdapterItem() {
init {
itemLayoutId = R.layout.item_bind_text_layout
}
override fun onSetItemData(data: Any?) {
super.onSetItemData(data)
updateAdapterItem()
}
override fun onItemBind(
itemHolder: DslViewHolder,
itemPosition: Int,
adapterItem: DslAdapterItem,
payloads: List<Any>
) {
super.onItemBind(itemHolder, itemPosition, adapterItem, payloads)
itemHolder.binding<ItemBindTextLayoutBinding>()?.data = itemData as? BindingData
}
}