Target Must Not Be Null Using Picasso Library
I implemented a listView using the Picasso Library 2.4.0 and I'm facing an issue. What happens: I launch the app using Android Studio, then I go to the specific fragment on which I
Solution 1:
The error occurs because holder.image
is null - and into()
specifically checks that the argument you pass in is not null.
When you use setTag()
/getTag()
, only a single object can be stored. Therefore when you call
view.setTag(holder);
view.setTag(holder1);
None of the data in holder
is saved - it is replaced with holder1
. Instead of having multiple ViewHolder
, you should just add another field to your existing ViewHolder
class:
classViewHolder {
ImageView image;
TextView url;
TextView price;
}
Then you can use just a single ViewHolder
:
holder = new ViewHolder();
holder.image = (ImageView) view.findViewById(R.id.photo);
holder.url = (TextView) view.findViewById(R.id.url);
holder.price = (TextView) view.findViewById(R.id.price);
view.setTag(holder);
Post a Comment for "Target Must Not Be Null Using Picasso Library"