如何在 RecyclerView Adapter 中为 picasso 设置 target viewholder

How to set target viewholder for picasso in RecyclerView Adapter

我在自定义 RecyclerView 适配器中使用 Picasso 库。在 onBindViewHolder() 中,绑定到视图持有者显示错误

public class ViewHolder extends RecyclerView.ViewHolder
    {
        ImageView image_view;
        public ViewHolder(View itemView)
        {
            super(itemView);
            image_view = (ImageView) itemView.findViewById(R.id.background);
        }
    }

 @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int 
    listPosition)
    {
        String abcd = "http://localhost/tack/poster1.jpg";
        Picasso.with((Context) mContext).load(abcd).into(holder.image_view);
    }

显示错误 - cannot resolve symbol 'image_view'

我需要将图像从 URL 绑定到 ImageView

请查看我的适配器并将其与您的适配器进行比较,然后根据需要更新所需的方法和参数。

public class FollowerAdapter1 extends RecyclerView.Adapter<FollowerAdapter1.MyViewHolder> {

    private Context context;

    public FollowerAdapter1(Context context) {
        this.context=context;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.custom_followers,null);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder( final MyViewHolder holder, final int i) {
                Glide.with(context)
                        .load("YOUR IMAGE URL")
                        .apply(RequestOptions.placeholderOf(R.drawable.placeholder))
                        .into(holder.ivfollower);

    }
    @Override
    public int getItemViewType(int position) {
        return position;
    }

    @Override
    public int getItemCount() {
            return 10;
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        private ImageView ivfollower,ivfollow;

        public MyViewHolder(View itemView) {
            super(itemView);
            ivfollower=itemView.findViewById(R.id.iv_follow_profile);

        }
    }
}