1

I want to create a custom epoxy model class in epoxy.HotelItemModel_() class is not generated in Epoxy Controller

@EpoxyModelClass(layout = R.layout.singlefood_layout)
abstract class HotelItemModel (@EpoxyAttribute var food: Food) : EpoxyModelWithHolder<HotelItemModel.FoodHolder>() {

    override fun bind(holder: FoodHolder) {
        holder.imageView.setImageResource(food.image)
        holder.titleView.text = food.title
    }

    inner class FoodHolder : KotlinHolder() {
        val imageView by bind<ImageView>(R.id.image)
        val titleView by bind<TextView>(R.id.title)
        val descView by bind<TextView>(R.id.desc)
    }
}  
Dmitrii Leonov
  • 1,331
  • 1
  • 15
  • 25
sri
  • 105
  • 9

1 Answers1

0

Try leaving constructor empty and putting Food object as optional field

@EpoxyModelClass(layout = R.layout.singlefood_layout)
    abstract class HotelItemModel() : EpoxyModelWithHolder<HotelItemModel.FoodHolder>() {

    @JvmField
    @EpoxyAttribute 
    var food: Food? = null
  // ...
  }
Dmitrii Leonov
  • 1,331
  • 1
  • 15
  • 25