I had the same issue and was able to solve it like this:
In fact it was due to my ListAdapter
which didn't managed properly the case when the whole list is refreshed. If so, what you want to do is keeping the items already displayed on the screen as-is.
To do so, in the method getView
of the Adapter when you get a recycled item, you must check if it's not already the one you want to display. If it's the case, just return it directly.
@Override
public View getView(int position, View convertView, ViewGroup container) {
ImageView imageView;
String src = this.getItem(position).getSrcThumbnail();
if (convertView == null) {
imageView = new ImageView(getContext());
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 120, getResources().getDisplayMetrics());
imageView.setLayoutParams(new GridView.LayoutParams(GridView.LayoutParams.MATCH_PARENT, height));
} else {
imageView = (ImageView) convertView;
// When you get a recycled item, check if it's not already the one you want to display.
String newSrc = (String) imageView.getTag();
if(newSrc.equals(src)){
// If so, return it directly.
return imageView;
}
}
loadBitmap(this.getItem(position).getSrcThumbnail(), imageView);
// Here you set the unique tag that allow to identify this item.
imageView.setTag(src);
return imageView;
}
TextView
's in items, showing ellipsized/truncated text ? – ReynaldoreynardnotifyDataSetChanged()
in quick succession, like each time you add one image ? – ReynaldoreynardGridView
must redraw itself and minimal flicker is normal, unless there's something that makes it slow forGridView
to load images. Does you adapter do something heavy ingetView()
? – ReynaldoreynardgetView()
? maybe you are not recycling the view or something like that. – Asceticism