0

I am using a Recycler view with ListAdapter<> with ViewBinding

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val binding: ItemMessageBinding =
            ItemMessageBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        return ViewHolder(binding)
    }

My viewholder class looks like this

inner class ViewHolder(
        private val binding: ItemMessageBinding
    ) : RecyclerView.ViewHolder(binding.root) {
        fun bind(message: Message) {
            binding.apply {
               
            }
        }
    }

I want to use different views for different chats. The main problem is my viewholder is taking binding as parameter. How can I pass both bindings and inflate accordingly ?

Ankit Verma
  • 124
  • 1
  • 11
  • For different you create separate `ViewHolder` and change the Binding Parameter as per layout . – ADM Feb 22 '22 at 05:15

0 Answers0