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 trialCharles Harpke
33,986 PointsAssume this code has an instance variable named listings that is an ActiveListings object. It holds an array of Listing
Trying to parse out the wording of the question. This is step one, and the error I get:
Bummer! You need to access the 'listings' instance variable within the onBindViewHolder method.
public void onBindViewHolder(ListingHolder holder, int position) {
Listing listing = activeListings.results[position]; // Set this variable!
}
// This is an excerpt from the full file.
public void onBindViewHolder(ListingHolder holder, int position) {
Listing listing; // Set this variable!
}
Charles Harpke
33,986 PointsI think I have it...NVM:
public void onBindViewHolder(ListingHolder listingHolder, int position) { final Listing listing = listings.results[position];
1 Answer
Jon Kussmann
Courses Plus Student 7,254 PointsHi Charles,
public void onBindViewHolder(ListingHolder holder, int position) {
Listing listing = listings.results[position]; // Set this variable!
}
The ActiveListings object is called "listings" so we will use that to call our method.. "results". "results" is an array and in order to get a certain object out of the array, we need to know its position. This is given to us with "position"
I hope this helps, if not let me know.
Charles Harpke
33,986 PointsCharles Harpke
33,986 PointsIt holds an array of Listing objects that can be accessed by the results property. Within the onBindViewHolder method below, use listings to set the listing variable to the Listing object specified by the position parameter....