Reputation: 45
I am getting the error : class "FlickrRecyclerViewAdapter" must either be declared abstract or implement method abstract method onBindViewHolder(VH, int) in 'Adapter'
While this error should be self explanitory, I have implemended onBindViewHolder and the error is still present.
Relvant Code -
public class FlickrRecyclerViewAdapter extends RecyclerView.Adapter {
private List<Photo> mPhotosList;
private Context mContext;
public FlickrRecyclerViewAdapter(Context context, List<Photo> photosList) {
mContext = context;
this.mPhotosList = photosList;
}
@Override
public void onBindViewHolder(FlickrImageViewHolder flickrImageViewHolder, int i) {
Photo photoItem = mPhotosList.get(i);
Picasso.with(mContext).load(photoItem.getmImage())
.error(R.drawable.placeholder)
.placeholder(R.drawable.placeholder)
.into(flickrImageViewHolder.thumbnail);
}
}
Thanks
Upvotes: 1
Views: 4673
Reputation: 22254
RecyclerView.Adapter
that you have extended has a method :
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position)
that you have to override. With the method signature that your are using you have to extend like this :
public class FlickrRecyclerViewAdapter extends RecyclerView.Adapter<FlickrImageViewHolder>
Upvotes: 0
Reputation: 157467
The definition of The adapter is
RecyclerView.Adapter<VH extends android.support.v7.widget.RecyclerView.ViewHolder>
where VH
is the a subclass of ViewHolder
. So you can either change the signature of you onBindViewHolder like
@Override
public void onBindViewHolder(RecyclerView.ViewHolder flickrImageViewHolder, int i) {
or change
extends RecyclerView.Adapter {
with
extends RecyclerView.Adapter<FlickrImageViewHolder> {
Upvotes: 8