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 trialvicente lee
6,271 PointsWeird bug
Not sure why this is happening, but whenever I click on say "french toast" I get a "german pancakes" toast. So I logged the index for the things that I'm clicking, and whenever I click the very first item, supposedly, the index should be 0. But what I'm logging is 7. And then when I click on some other item, I'm also logging 7. Any ideas as to what I'm doing?
Kareem Jeiroudi
14,984 PointsOh my god! Thnx! you saved my life. I've had this issue before with another app, and now I'm having it again, and couldn't resolve it. Thanks for finally finding a solution!
1 Answer
Seth Kroger
56,413 PointsRecall that the Adapter is for the entire list, and the ViewHolders are for the individual items. If you make mIndex a member of the adapter, it will be set to whatever the index was for the last ViewHolder to be bound.
vicente lee
6,271 Pointsvicente lee
6,271 PointsOk, never mind, silly me. The
mIndex
field should be a member of the nested class. Can anyone explain why the mIndex field has to be inside the ListViewHolder class? Why does it act buggy when declaring it inside the ListAdapter class?