title: Updating images dynamically from URL with Android
body: <p>So I have this program that grabs the RSS feed at <a href="http://www.muttville.org/mutts/feed" rel="nofollow noreferrer">http://www.muttville.org/mutts/feed</a> and displays a list of the available dogs, basically filling out each item in a ListView with an image of the dog on the left, and the headline about the dog on the right.</p>
  
  <p>My application executes and grabs and parses the XML feed fine. onCreate, it stores the image URL as a string in each item. I have an RSSFeed data structure, which is basically an array of RSSItem objects. The problem is figuring out how to update the images asynchronously.</p>
  
  <p>I have an imageDownloader that I actually got from the Android dev blog at Google that updates the images and stores them, but the preload is very long. I'd rather begin displaying the items immediately and updating the images as I get them. Annoyingly, the listview scrolls really unresponsively at first as well, calling my imageDownloader to retrieve the items again. Is there some way I can make the ImageViews just grab a pointer to an ImageView object in the RSSItem, and then just update that?</p>
  
  <p>I'm pretty new to Android development, so there's a good chance I don't realize something basic. Here's my adapter code:</p>
  
  <p>private class FeedItemAdapter extends ArrayAdapter {</p>
  
  <pre><code>    private List&lt;RSSItem&gt; items;
  
      public FeedItemAdapter(Context context, int textViewResourceId, List&lt;RSSItem&gt; items) {
          super(context, textViewResourceId, items);
              this.items = items;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
              View v = convertView;
              if (v == null) {
                  LayoutInflater vi = 
                      (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                  v = vi.inflate(R.layout.displayitem, null);
              }
  
              RSSItem o = items.get(position);
              if (o != null) {
                      ImageView tt = (ImageView) v.findViewById(R.id.leftimage);
                      TextView bt = (TextView) v.findViewById(R.id.righttext);
                      if (tt != null) {   
                          //get image from url string
                          imageDownloader.download(o.getImageString(), tt);
                      }
                      if(bt != null){
                            bt.setText(feed.getItem(position).getTitle());
                      }
              }
              return v;
      }
  
  
  }
  </code></pre>