How i can remove item in a recyclerview with view binding from an adapter?

How i can remove item in a recyclerview with view binding from an adapter?


class RecyclerAdapter(val context: Context, private val animalList: MutableList<Animals>): RecyclerView.Adapter<BaseViewHolder<*>> () { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<*> { return AnimalViewHolder( LayoutInflater.from(context).inflate(R.layout.item_list, parent, false) ) } override fun onBindViewHolder(holder: BaseViewHolder<*>, position: Int) { when (holder) { is AnimalViewHolder -> holder.bind(animalList[position], position) else -> throw IllegalArgumentException("no run") } } override fun getItemCount(): Int { return animalList.size } inner class AnimalViewHolder (itemView: View): BaseViewHolder<Animals>(itemView){ override fun bind(item: Animals, position: Int) { itemView.txt_name_animal.text = item.name Glide.with(context).load(item.image).into(itemView.profile_image) if (item.isDomestic) { itemView.txt_is_visible.text = context.getString(R.string.domestico) } else { itemView.txt_is_visible.text = context.getString(R.string.no_domestico) } } } }

submitted by /u/ggcano
[link] [comments]