title: Create animation in imageviews
body: <p>I have an imageview with a default image. Now when I try to click it, I want it to animate that displays 4 frames of images. How could I accomplish this, I tried a simpler approach (more of a dumb approach) by changing the imageresource 4 times, as expected the image changes so fast that the animating image effect is not visible. Any ideas?</p>
  
  <p>I tried this approach:</p>
  
  <pre><code>Gem = (ImageView)v;
      Gem.setImageResource(com.example.gems.R.drawable.bd1);
      Gem.postDelayed(new Runnable() {
          public void run() {
              Gem.setImageResource(com.example.gems.R.drawable.bd2);
              Gem.postDelayed(new Runnable() {
                  public void run() {
                      Gem.setImageResource(com.example.gems.R.drawable.bd3);
                      Gem.postDelayed(new Runnable() {
                          public void run() {
                              Gem.setImageResource(com.example.gems.R.drawable.bd4);
                              Gem.postDelayed(new Runnable() {
                                  public void run() {
                                  }
                              }, 500);
                          }
                      }, 500);
                  }
              }, 500);
          }
      }, 500);
  </code></pre>
  
  <p>It worked, but is there a better way to this without coding too much lines? I have 25 kinds of images and each image has 4 frames. </p>
  
  <p>EDIT:</p>
  
  <p>I tried using xml transition files: </p>
  
  <p>Java file:</p>
  
  <pre><code>Resources res = this.getResources();
      Gem = (ImageView)v;
      TransitionDrawable transition;
  
      transition = (TransitionDrawable)
              res.getDrawable(R.drawable.blue_diamond_animation);
      Gem.setImageDrawable(transition);
      transition.startTransition(3000);
  </code></pre>
  
  <p>xml file:</p>
  
  <pre><code> &lt;transition xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;item android:drawable="@drawable/bd1"&gt;&lt;/item&gt;
    &lt;item android:drawable="@drawable/bd2"&gt;&lt;/item&gt;
    &lt;item android:drawable="@drawable/bd3"&gt;&lt;/item&gt;
    &lt;item android:drawable="@drawable/bd4"&gt;&lt;/item&gt;
    &lt;item android:drawable="@drawable/invi"&gt;&lt;/item&gt;
   &lt;/transition&gt;
  </code></pre>
  
  <p>This seems to work, but I don't want to draw this images in a transition. I want to change the background in a transition. I tried changing this <code>android:drawable</code> to <code>android:drawable</code> but it doesn't work.</p>