Frame Animation on button click in Android
<p>My Problem is I have Some Images &amp; I used frame animation to display this images on click event of button but if i click button first time the image is display in sequence &amp; if i click this button another time that time the image is not displayed. following is my code.</p>

<p>Animation.java file:- </p>

<pre><code>public class Animation extends Activity {

    Button mBtnOK;
    AnimationDrawable frameAnimation;
    ImageView imgView;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mBtnOK = (Button) findViewById(R.id.mBtnOK);
        mBtnOK.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                animate();
            }
        });

    }

    private void animate() {
        imgView = (ImageView) findViewById(R.id.simple_anim);
        imgView.setVisibility(ImageView.VISIBLE);
        imgView.setBackgroundResource(R.anim.simple_animation);
        AnimationDrawable frameAnimation = (AnimationDrawable) imgView
                .getBackground();
        frameAnimation.start();
        frameAnimation.setOneShot(true);
    }
}
</code></pre>

<p>Animation file:-</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
 &lt;animation-list xmlns:android="http://schemas.android.com/apk/res/android" id="selected" android:oneshot="false"&gt;
  &lt;item android:drawable="@drawable/monkey_1" android:duration="50" /&gt;
  &lt;item android:drawable="@drawable/monkey_2" android:duration="50" /&gt;
  &lt;item android:drawable="@drawable/monkey_3" android:duration="50" /&gt;
  &lt;item android:drawable="@drawable/monkey_4" android:duration="50" /&gt;
  &lt;item android:drawable="@drawable/monkey_5" android:duration="50" /&gt;
  &lt;item android:drawable="@drawable/monkey_6" android:duration="50" /&gt;
  &lt;item android:drawable="@drawable/monkey_7" android:duration="50" /&gt;
  &lt;item android:drawable="@drawable/monkey_8" android:duration="50" /&gt;
  &lt;item android:drawable="@drawable/monkey_9" android:duration="50" /&gt;
  &lt;item android:drawable="@drawable/monkey_10" android:duration="50" /&gt;
 &lt;/animation-list&gt;
</code></pre>
