The following method makes an AnimationDrawable object animate when it's 
first called.


  private void setPersonagemDireita(AnimationDrawable d) {

    //View is an ImageView object already loaded in the layout
    //d is a working AnimationDrawable
    view.setImageDrawable(d);
    view.post(new Runnable() {
        @Override
        public void run() {
            AnimationDrawable animate = (AnimationDrawable) view.getDrawable();
            animate.start();
        }
    });}


When this is first called, the ImageView shows an animated drawable, as 
expected. But, further calls of the method will change the ImageView image 
to a static frame of the AnimationDrawable.

The expected result was that the new AnimationDrawable would animate, but 
it's just a static frame.

Somehow, sometimes when the method is called, the Animation starts and keep 
going, but other times it will just be static.

What can be done for the ImageView to start it's AnimationDrawable as 
expected?

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/1a349ef2-c9bf-4298-ac06-f3be45d3bbff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to