2016-07-05 8 views
0

«Привет всем, я работаю над залпом с recyclerviw Однако, я потратил много времени, чтобы выяснить, ошибку в этой части:.не удается разрешить setImageUrl

viewHolder.giftPicture.setImageUrl (IMAGE_URL, mImageLoader)

Я не знаю, почему он говорит: «Не удается разрешить setImageUrl», он работает в моих других частях кода. Может ли кто-нибудь помочь мне? Спасибо.

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); 
     } 
    } 

} 
+1

нужно бросить ImageView в NetworkImageView – Muthu

+0

или установить giftPicture в NetworkImageView в viewholder – Muthu

ответ

1

ImageView не имеет метод setImageUrl вам нужно либо бросить giftPicture, как NetworkImageView при вызове Uri или изменить

ImageView giftPicture;

к

NetworkImageView giftPicture;

в ViewHolder

+0

Спасибо большое. Я меняю giftPicture на использование в NetworkImageView в findViewByID, но не изменял объявление переменной. Это проблема. Огромное спасибо. – eluo7

+0

Класс NetworkImageView теперь называется «ANImageView», – GabrielBB

Смежные вопросы