0

I have a simple .xml layout file that has a simple ImageView, that I want to switch images on. I decided to go ahead and do it with FrameAnimations, using the AnimationDrawable API.

I have managed to create my animation file in "drawable/file.xml", here is the code:

<?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/image_010_1" android:duration="1000" />
    <item android:drawable="@drawable/image_010_2" android:duration="1000" />
</animation-list>

Now, Here is the code that should start my animation:

Image1.setBackgroundResource(R.drawable.image_010);
AnimationDrawable animation = (AnimationDrawable) Image1.getBackground();
animation.start();

For some reason, When i run the app I just see the first frame, and the next image does not come after 1000 milis, or at all! What am I doing wrong? Thanks!

rel-s
  • 6,108
  • 11
  • 38
  • 50

1 Answers1

0

so I managed to solve this problem by adding a Runnable to my ImageView:

    image.post(new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub
            animation.start();
        }
    });
rel-s
  • 6,108
  • 11
  • 38
  • 50