0

I was following the Google provided example of how to use AnimationDrawable with an ImageView. You can find it here: http://developer.android.com/guide/topics/graphics/drawable-animation.html

 image.setBackgroundResource(R.drawable.run_animation);

        frameAnimation = (AnimationDrawable) image.getDrawable();
        frameAnimation.start();

drawable file run_animation:

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="false">

    <item
        android:drawable="@drawable/iv1"
        android:duration="500" />

    <item
        android:drawable="@drawable/iv2"
        android:duration="500" />
    <item
        android:drawable="@drawable/iv3"
        android:duration="500" />
    <item
        android:drawable="@drawable/iv4"
        android:duration="500" />

</animation-list>

Upon execution i am receciving this error on logcat

java.lang.ClassCastException: android.graphics.drawable.ColorDrawable cannot be cast to android.graphics.drawable.AnimationDrawable

please help me.

kashyap
  • 81
  • 1
  • 2
  • 7

0 Answers0