Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Android Fragments Introducing Fragments Handling Clicks

Kartik Gupta
Kartik Gupta
6,454 Points

RecyclerView --------Relation betwwen bindView and Onclick methods ----------

Hi , in this video , we need to get the index of the view which is clicked and this is being obtained from bindview method, so I am not getting how it is happening?

2 Answers

Alok Singh
PLUS
Alok Singh
Courses Plus Student 3,397 Points

The bind method is taking the position from onBindView method's position parameter for current view to be displayed and bind data to it so when onClick method is called it can also do the same by listening to the correct index positioned view.

Sachin Jayaram
Sachin Jayaram
5,461 Points

Why don't you debug, it will help you understand the code flow really well. Use breakpoints and check how the code flow works.