Up to this point, I wrote listeners in RecyclerView right in onBindViewHolder . But I saw somewhere that you can’t do that. What about then? Can the perfect code?

  • There is no perfect code, there is a reasonable choice - pavlofff
  • I read your answer. Now I have two options. Or yours. Ie either get the position by getAdapterPosition() or create the bind method and pass the listener and the position to it. What is better, I do not understand. - Flippy

1 answer 1

I advise you to use this solution: ItemClickSupport . This decision is used by many. I made for myself in one class.

  • Are you from Samara?) Thanks for the lib) - Flippy
  • Yes, I am from Samara - pavel163
  • Cool me too) but can I talk to you? On the topic of career. - Flippy
  • I think that for such a simple action you can also throw your callback, just a couple of lines than to connect it. - pavlofff
  • In one class, and the same callbacks are used. Just a little more convenient. but this is my opinion. - pavel163