title: android dynamically show list with text and images, improving performance
body: <p>I need to display a list of items each with text and various number of images. </p>
  
  <p>I'm currently using a ListView with custom adapter to show these items. And for each item, I used a HorizontalScrollView with a LinearLayout in it to display the images. In the getView method of the ListView, I read the image URIs of each item and dynamically create ImageViews, then load the images asynchronously. I used a ViewHolder to hold the LinearLayout which contains all the ImageViews of each item.</p>
  
  <p>The problem is, if I scroll down the ListView and scroll back, I'll lost the content of the item, which means I have to load the images again. And most of the images are too large and loads very slow. Actually on my app the screen can show only about 2 or 3 items once, so the scroll happens very frequently.</p>
  
  <p>I have some ideas to improve this, but I'm not sure whether one of them will results better.</p>
  
  <ol>
  <li>Since I'm just showing a thumbnail of each image, maybe I can save the thumbnails into a temp dir and load them dynamically, loading small images will be much faster. And I might have to clear that temp dir when it gets large.</li>
  <li>I have at most 9 images for each item, so it might still be slow even if I cache the thumbnails and scroll frequently. And maybe I have to show the list manually instead of using ListView, so each item will not be reused, and the load will happen only once. But, the list will grow large in the future, if I preserve like 100 items in the LinearLayout my app may still crash.</li>
  <li>Other better options...</li>
  </ol>
  
  <p>Any advice will be helpful! Thanks!</p>