This is my getView()
.
I am obviously doing something wrong here, because the FIRST item of my list always shows no picture.
The problem here is with the convertview
because if I don't recycle it, there is no problem.
Please what am I doing wrong??
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView==null) //IF I DELETE THIS IF EVERYTHING OK!!!
convertView = inflater.inflate(R.layout.square, null);
ImageView image = (ImageView) convertView.findViewById(R.id.background_image);
if (data.get(position).isFollowed()) {
int approprieteimage = getApproppreiateImage(data.get(position));
Picasso.with(context).load(approprieteimage).centerCrop().error(R.drawable.no_image_available).transform(new TealTransformation(context)).fit().into(image);
} else {
int approprieteimage = getApproppreiateImage(data.get(position));
Picasso.with(context).load(approprieteimage).centerCrop().error(R.drawable.no_image_available).fit().into(image);
}
AbsListView.LayoutParams layoutParams = new AbsListView.LayoutParams(width / 2, width / 2);
convertView.setLayoutParams(layoutParams);
return convertView;
}
.centerCrop()
and.fit()
from your Picasso command. I believe it has something to do with Picasso needing a first layout to be able to execute those actions. – Illogicalif (convertview=null)
as it is , does the thing work ? – Buonomo