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 Google Play Services Interacting with Your API Defining onBindViewHolder()

Charles Harpke
Charles Harpke
33,986 Points

Assume 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!
}
ListingsAdapter.java
// This is an excerpt from the full file.

public void onBindViewHolder(ListingHolder holder, int position) {
  Listing listing; // Set this variable!
}
Charles Harpke
Charles Harpke
33,986 Points

It 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....

Charles Harpke
Charles Harpke
33,986 Points

I think I have it...NVM:

public void onBindViewHolder(ListingHolder listingHolder, int position) { final Listing listing = listings.results[position];

1 Answer

Jon Kussmann
PLUS
Jon Kussmann
Courses Plus Student 7,254 Points

Hi 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.