1

We have ListView with Images. Images downloads from our server. Then saves to Storage and puts to cache like this:

private static final Hashtable<String, Bitmap> cachePhoto = new Hashtable<String, Bitmap>();

So in getView after 1st added we gets Images from cache and sets it to ImageView:

i.setImageBitmap(photo);

And now we have some lags while scrolling on many devices. But wanted to smooth scrolling. How can i avoid lags?

  • There is not enough info in your question to find out what is causing the performance lag. Maybe you should post your `getView()` and the place where you update the cache etc. **Recommendation**: You should use volly (and its `NetworkImageView`), no point re-inventing the wheel: http://stackoverflow.com/q/17571759/827110 – Amulya Khare Nov 21 '13 at 10:25
  • In getView i invoke my ViewHolder and trying to set Image. 1) Tries to take image from sd-card (and cache). 2) if no img, then downloads from web in AsyncTask. So lags in getView is when creating AsyncTask... – Suvitruf - Andrei Apanasik Nov 21 '13 at 10:57
  • How do you know it lags when creating `AsyncTask`? You think or you have carried out test to figure out that this is the bottleneck? In either case, I think its very hard to fix your problem unless you post code. As there is no general solution.. you must be doing something which causes the lag.. – Amulya Khare Nov 21 '13 at 11:03

1 Answers1

0

we need more of your code or I can just recommend you to check this library https://github.com/thest1/LazyList

Dlash
  • 154
  • 3
  • 11