因此,我使用的是AirBNB Epoxy (视图持有者版本),而且我似乎找不到可以在AirBNB Epoxy中设置onClickListeners的信息。任何信息都有帮助,谢谢。
发布于 2022-04-05 05:15:49
根据环氧树脂文件
@EpoxyModelClass(layout = R.layout.model_button)
abstract class ButtonModel : EpoxyModelWithHolder<ButtonModel.Holder>() {
// Declare your model properties like this
@EpoxyAttribute
@StringRes
var text = 0
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var clickListener: View.OnClickListener? = null
override fun bind(holder: Holder) {
// Implement this to bind the properties to the view
holder.button.setText(text)
holder.button.setOnClickListener(clickListener)
}
class Holder : EpoxyHolder() {
lateinit var button: Button
override fun bindView(itemView: View) {
button = itemView.findViewById(R.id.button)
}
}
}应该直接实例化生成的模型,并为每个属性设置一个setter:
ButtonModel_()
.id(1)
.text(R.string.my_text)
.clickListener { view -> /* do something */ }https://stackoverflow.com/questions/71609611
复制相似问题