gpt4 book ai didi

java - 无法解析 setImageUrl

转载 作者:行者123 更新时间:2023-12-02 03:30:13 25 4
gpt4 key购买 nike

"Hi everyone, I am working on the volley with recyclerviw. However, I spent a long time to figure out a bug. In this part:

viewHolder.giftPicture.setImageUrl(IMAGE_URL, mImageLoader);

I don't know why it keeps saying 'Cannot resolve setImageUrl', it works in my other parts of code. Can anyone help me? Thanks."

public class NavigationRecyclerAdapter extends RecyclerView.Adapter<NavigationRecyclerAdapter.ViewHolder> {

private Context mContext;
private List<Gift> mGifts;
ImageLoader mImageLoader;
private static final String IMAGE_URL = "http://media2.intoday.in/indiatoday/images/stories/google-doodle-story_647_032416125016.jpg";

NavigationRecyclerAdapter(Context context, List<Gift> gifts) {
mGifts = gifts;
mContext = context;
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.card_view, viewGroup, false);

return new ViewHolder(view);
}

@Override
public void onBindViewHolder(ViewHolder viewHolder, int i) {
Gift gift = mGifts.get(i);
viewHolder.giftTitle.setText(gift.title);
viewHolder.currentPrice.setText(gift.currentPrice);

// Get the ImageLoader through your singleton class.
mImageLoader = MySingleton.getInstance(mContext).getImageLoader();

// Set the URL of the image that should be loaded into this view, and
// specify the ImageLoader that will be used to make the request.
viewHolder.giftPicture.setImageUrl(IMAGE_URL, mImageLoader);
// viewHolder.giftPicture.setImageResource(R.drawable.userimg);


viewHolder.giftTitle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Context context = view.getContext();
context.startActivity(new Intent(context, AddGiftsActivity.class));`enter code here`
}
});
}

@Override
public int getItemCount() {
return mGifts.size();
}

public static class ViewHolder extends RecyclerView.ViewHolder {

// private final TextView mTextView;
CardView mCardView;
TextView giftTitle;
TextView currentPrice;
ImageView giftPicture;

ViewHolder(View view) {
super(view);
mCardView = (CardView)itemView.findViewById(R.id.cv);
giftTitle = (TextView)itemView.findViewById(R.id.gift_title);
currentPrice = (TextView)itemView.findViewById(R.id.current_price);
giftPicture = (NetworkImageView)itemView.findViewById(R.id.gift_picture);
}
}

}

最佳答案

ImageView 没有 setImageUrl 方法,您需要在调用 Uri 时将giftPicture 转换为 NetworkImageView 或更改

ImageView giftPicture;

NetworkImageView giftPicture;

在ViewHolder中

关于java - 无法解析 setImageUrl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38202096/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com