title: ANDROID : Frame by Frame animation not working?
body: <p>I am trying to get frame by frame animation but its giving me a force close and I am not sure as to why it is giving me a force close. It all seems alright to me.</p>
  
  <p>Here is my code i hope some one can help?
  Thanks in advance.</p>
  
  <p>AnimationTest.java</p>
  
  <pre><code>import android.app.Activity;
  import android.graphics.drawable.AnimationDrawable;
  import android.graphics.drawable.BitmapDrawable;
  import android.os.Bundle;
  import android.widget.ImageView;
  
  public class AnimationTest extends Activity {
  
  AnimationDrawable animation;
  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
      AnimationDrawable animation = new AnimationDrawable();
      animation.addFrame(getResources().getDrawable(R.drawable.up), 500);
      animation.addFrame(getResources().getDrawable(R.drawable.down), 500);
  
      animation.setOneShot(false);
  
      ImageView imageAnim =  (ImageView) findViewById(R.id.imageView1);
      imageAnim.setBackgroundDrawable(animation);
  
      // start the animation!
      animation.start();
  } 
  
  }
  </code></pre>
  
  <p>activity_main.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"&gt;
  
      &lt;ImageView android:id="@+id/imageView1"
          android:src="@drawable/down"
          android:layout_height="wrap_content"
          android:layout_width="wrap_content"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>