title: Android - Issue with lazy loading images into a ListView
body: <p>This is a very common scenario: displaying images in a ListView which have to be downloaded from the internet.</p>
  
  <p>Right now I have a custom subclass of ArrayAdapter which I use for the ListView. In my getView() implementation of the ArrayAdapter, I spawn a separate thread to load an image. After the loading is done, it looks up the appropriate ImageView and sets the image with ImageView.setImageDrawable(). So the solution I used is kind of similar to this one: <a href="https://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview">Lazy load of images in ListView</a></p>
  
  <p>The problem I'm having is that as soon as I make the call to setImageDrawable() on the ImageView, the ListView somehow refreshes all currently visible rows in the list! This results in kind of an infinite loop:</p>
  
  <ol>
  <li>getView() is called</li>
  <li>thread is spawned to load image</li>
  <li>image is loaded; setImageDrawable() is called on ImageView</li>
  <li>ListView picks it up for some reason and refreshes itself</li>
  <li>For the ListView to refresh, getView() is called for each visible row, so we go back to step 1 and the whole thing repeats itself</li>
  </ol>
  
  <p>So as far as I can see, the solution proposed in "Android - How do I do a lazy load of images in ListView" (see link above) simply doesn't work. It might look like it does, but it will run very slow because in the background, it keeps reloading the currently visible rows. </p>
  
  <p>Did anyone encounter this before and/or have a solution for this?</p>