K
K
Kirill Matrosov2018-07-10 21:20:46
Android
Kirill Matrosov, 2018-07-10 21:20:46

RecycleView. How to understand which part of the item was clicked?

There is a RecycleView. The list item has two TextView and one Image
How to determine which element from this item was clicked (for example, an image)?

inner class holder(itemView: View?) : RecyclerView.ViewHolder(itemView) {
        init {
            itemView?.setOnClickListener {
               //есть it, отвечающий за view
            }
        }
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Matrosov, 2018-07-10
@sharpfellow

I did so

inner class holder(itemView: View?) : RecyclerView.ViewHolder(itemView) 
        private val play: ImageView? = itemView?.findViewById(R.id.main_vase_rallies_play)

        init {
            itemView?.setOnClickListener {
                println("all view")
            }
            play?.setOnClickListener {
                println("play")
            }

        }
}

Is this good practice?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question