How do I run an animation for a short period of time?
<p>I have a looping animation I want to present for an image button before a static image is used; on each button press.  Is there a way to run this animation for around 2000 milliseconds then switch over to the image.  What I have tried just results in a pause then the static image.</p>

<pre><code>    button.setOnClickListener(new View.OnClickListener(){         

      @Override
   public void onClick(View v) {

       animationrun();
             long time = System.currentTimeMillis();
             time += 2000;
             while(time &gt; System.currentTimeMillis())
             {}

       select();        


   }

     });

     public void animationrun()
 {
 button.setBackgroundResource(R.drawable.ball_anim);
        animation = (AnimationDrawable)button.getBackground();
        animation.start();
 }



      public void select()
     { 
     button.setBackgroundResource(R.solidImage); 
     }
</code></pre>

<p>SOLUTION: <a href="http://www.facebook.com/topic.php?uid=128857303793437&amp;topic=74" rel="nofollow">http://www.facebook.com/topic.php?uid=128857303793437&amp;topic=74</a></p>
