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
Johnson Ly
2,467 PointsHow does the getView and adapter work?
For the custom adapter, we are creating, how exactly does the getView() and all of the other methods pertaining to the custom method actually work? Specifically, I know we get the length of the Day array data and return its position, but how is it going through the array? Is there some kind of loop working in the background running through the array? Thanks for the help
1 Answer
Nicolas Hampton
44,725 PointsCheck this out.
http://www.codeofaninja.com/2013/09/android-viewholder-pattern-example.html
basically, the listview understands that the convertView has already been created when the item scrolls off the page, but when it comes back, it thinks it has to reinflate and reattach all the information. We're creating a capsule that we tag to that listview, the viewholder, that has the findViewById data we attached the first time, so when the non-null convertView comes back, we don't have to set it up all over again, we just use the info we tagged to it the last time.