When you execute a lazy ListView, this is because you want to speed it up. Turning it off is not the best solution. So what you can do is implement the basic cache system so that you don't have to download and install ImageView again and again.
The easiest way to do this is to implement a HashMap with URLs as keys and bitmaps as values. Something like that:
Map cache = new HashMap(); // then, on your lazy loader Bitmap image = cache.get(urlOfTheImage); if( image == null ){ // download and decode the image as normal, // then assign the decoded bitmap to // the 'image' variable cache.put(image); } imageView.setImageBitmap(image);
If these images are always the same, which means that every time you open the application the same images are downloaded, then you better save these images in the file system and use them from there.
On the other hand, if images tend to change, you can implement some interesting things: use SoftReferences . There's an explanation in this video . This can also be used if you are downloading images from the file system.
Edit
As for your comment, I highly recommend that you watch the video that I posted. It's one hour, but it's really worth the effort. Using an adapter, checking if convertView is null is just an easy way to improve performance, although there are other methods that will further enhance your application. Also, if you had problems using this trick, it is due to the fact that you are probably using it incorrectly. Remember: even if you are not reinventing the ideas, you need to establish the meaning of each of the children's ideas, otherwise you will encounter some problems.
Cristian
source share