0

I want to load an image from an URL into an imageView within a nested RecyclerView. I use the Glide library for that.

@Override
public void onBindViewHolder(@NonNull InnerAdapter.ViewHolder holder, int position) {
    holder.textView.setText(movieList.get(position).getName());

    Glide.with(context).load("https://image.tmdb.org/t/p/w500" + movieList.get(position).getImage()).into(holder.imageView);
}

I pass the Activity context through the recyclerViews, but when I want to run the app, it fails with this message:

error: cannot access Fragment

Glide.with(context).load("https://image.tmdb.org/t/p/w500" + movieList.get(position).getImage()).into(holder.imageView);

class file for android.support.v4.app.Fragment not found

What can I do to fix that?

1 Answers1

0

You don't need to pass activity context to the adapter, instead do this

 Glide.with(holder.itemView.getContext()).load("https://image.tmdb.org/t/p/w500" + movieList.get(position).getImage()).into(holder.imageView);
Sreehari K
  • 887
  • 6
  • 16