I am using a ListView containing images. These images are downloaded from the Internet inside the adapter. Therefore, I use UniversalImageDownloader .
Unfortunately, scrolling through the ListView is βlaggingβ for a short time, as soon as I scroll down to where to download new content.
I confidently expected that behavior like ListView scrolls perfectly smoothly, but loading an image can, of course, take longer - which should not affect the smoothness of scrolling.
In addition, when I scroll through the backup, lag also occurs. It seems that the images are not cached properly.
Perhaps my ImageLoader settings are not configured correctly?
Am I doing something wrong in my adapter?
ListView contains about 20-30 images with dimensions of 640x320 (about 150kb)
Below you can see my adapter, as well as ImageLoader. (The Downloader class is just a wrapper class for UniversalImageDownloader)
public class Downloader { public static void initialize(Context c) {
And adapter:
public class EventListAdapter extends ArrayAdapter<Event> { private List<Event> mList; private DisplayImageOptions options; public EventListAdapter(Context context, int list_item_resource, List<Event> objects) { super(context, list_item_resource, objects); mList = objects; options = Downloader.getDisplayOptions(); } @Override public View getView(int position, View convertView, ViewGroup parent) { Event event = mList.get(position); // A ViewHolder keeps references to children views to avoid unneccessary calls to findViewById() on each row. ViewHolder holder = null; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.normalevent_list_item, parent, false); holder = new ViewHolder();; holder.eventimage = (ImageView) convertView.findViewById(R.id.ivEventImage); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } if (event != null) { holder.eventimage.setImageResource(R.drawable.loading); // Load image, decode it to Bitmap and display Bitmap in ImageView Downloader.getInstance().displayImage(event.getImageOneURL(), holder.eventimage, options); } return convertView; } private static class ViewHolder { ImageView eventimage; } }