title: Image (from web) in the Android ListView always reloaded when appears
body: <p>I have a <code>ListView</code> than contains a list of image created from web link (e.g. <code>http://www...image.jpg</code>) with the istruction:</p>
  
  <pre><code>Drawable d = LoadImageFromUrlWeb(TopTen_LinkImg);
  imageTopTenView.setImageDrawable(d);
  </code></pre>
  
  <p>I have created a custom <code>ArrayAdapter</code> (both simple and optimized with "holder" same result).</p>
  
  <p>The problem is that each image when appear in the display is uploaded from web and browse the page list is impossible (too slow).</p>
  
  <p>There is a code that assign to <code>ImageView</code> the permanent image.</p>
  
  <p>The code is:</p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent)
      {
      LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View rowView = inflater.inflate(R.layout.row_top_ten, null);
      ImageView imageTopTenView = (ImageView)rowView.findViewById(R.id.imageTopTen);
      String TopTen = (String)ArrayDatiTopTen.get(position);
      String[] ArrayTopTen=TopTen.split(",");
      String TopTen_LinkImg=(String)ArrayTopTen[0];
      Drawable d = LoadImageFromUrlWeb(TopTen_LinkImg);
      imageTopTenView.setImageDrawable(d);
      return rowView;
      }
  </code></pre>
  
  <p>Perhaps the solution is populate the listView using programmatically code:</p>
  
  <pre><code>ListView listView=(ListView) findViewById(R.id.listView);
  ...
  listView.addView(...)
  ...
  </code></pre>
  
  <h2>SOLVED</h2>
  
  <p>I have solved creating an Drawable array and filling this array with the image before use in <code>ArrayAdapter</code></p>
  
  <pre><code>// Define:
  Drawable imageCache[]=new Drawable[100];
  </code></pre>
  
  <p>then:</p>
  
  <pre><code>//loop to popolate array
  imageCache[ct]=LoadImageFromUrlWeb(Link);
  </code></pre>
  
  <p>In the <code>ArrayList</code> I use:</p>
  
  <pre><code>...
  imageTopTenView.setImageDrawable(imageCache[position]);
  return rowView;
  ...
  </code></pre>
  
  <p>From url string to drawable:</p>
  
  <pre><code>private Drawable LoadImageFromUrlWeb(String url)
      {
          try
          {
              url=url.replaceAll(" ", "%20");
              InputStream is = (InputStream) new URL(url).getContent();
              Drawable d = Drawable.createFromStream(is, "src name");
              return d;
          } 
          catch (Exception e)
          {
              Log.w("LoadImageFromUrlWeb",e.toString());
              return null;
          }
      }       
  </code></pre>