Group Group Group Group Group Group Group Group Group

Kotlin recyclerview

#1

Hi,

i follow some tutorials here.
But what i missing is the hint, how can i properly highlight a selected item on RecyclerView?
I handle the cllick event, but how can i set or change for example the background color

here is my snippet for the viewholder:

inner class ViewHolder(val binding: NewArticleCategoryItemRowBinding) : RecyclerView.ViewHolder(binding.root),
View.OnClickListener {

    init {
        binding.root.setOnClickListener(this)
    }

    fun bind(item: ArticleCategory) {
        binding.viewmodel = NewArticleCategoryItemViewModel(item)
        binding.executePendingBindings()
    }

    /**
     * List click
     */
    override fun onClick(view: View) {
        selectedCategoryItem = items[position]

    }

}

Thanks for any help or hints

#2

@tommynocker Do you still have issues with this?

#3

Yes, can you give me a hint?