title: How do I selectively invalidate cached gallery images?
body: <p>I have a <a href="http://developer.android.com/reference/android/widget/Gallery.html" rel="nofollow">gallery</a> widget in my Android application, displaying images of cars (it's not really cars, but cars works as an example). The gallery shows one model of car per item in the gallery, so we might have a gallery like:</p>
  
  <ol>
  <li>Ford Model T</li>
  <li>Porsche 911</li>
  <li>Ford Mustang</li>
  </ol>
  
  <p>When the user long presses on an item in the gallery, they can select a new image for the car in question &mdash; so if the user long presses on the Ford Mustang image, they see a new gallery of pictures of Ford Mustangs, and they can pick the image that they actually want to see in the main gallery (maybe they want to see a red one instead of a yellow one).</p>
  
  <p>This is working pretty well in code &mdash; I just have an array of ints, where there's one int in the array for each model of car, and each int represents an index for an image.</p>
  
  <p>The user selects a new image and then the log says:</p>
  
  <pre>
  MoreCarImagesGallery: User selected image 3 for car with ID 219 (Ford Mustang)
  MainGalleryAdapter: Setting selected image (3) for car at position 2
  </pre>
  
  <p>The <a href="http://developer.android.com/reference/android/widget/BaseAdapter.html" rel="nofollow">adapter</a> getView() then does:</p>
  
  <pre><code>Image img = imageLookup.getImageForCar(car.id, selectedImageIndexes[position]);
  </code></pre>
  
  <p>However! When I go back to the main gallery, the previously displayed image for the car in question is still showing. But! When I scroll a few items to the left or right away from the displayed car, and then scroll back to that car, the image updates to the "new" (user selected) image.</p>
  
  <p>So obviously the gallery is doing some caching of images from my adapter. I probably want that to keep happening, because I imagine the gallery would be very laggy on slower phones without that caching in place.</p>
  
  <p>How do I invalidate images in my gallery in order to force my adapter getView() to return the "new" image?</p>