Billabong
Billabong

Reputation: 467

Multiple AnimationDrawables at the same time

Is it possible to generate 2 animationdrawables at the same time?

I tried it with threads:

Thread t1 = new Thread(){
public void run(){
    runOnUiThread(new Runnable() { 
        public void run() 
        { 
animation1.start(); 
 }   

}};
Thread t2 = new Thread(){
public void run(){
   runOnUiThread(new Runnable() { 
        public void run() 
        { 
animation2.start(); 
 }   
}};

t1.start();
t2.start();

This doesn't work. I load the resources for the animation from a xml-file.

Upvotes: 0

Views: 185

Answers (1)

Koso
Koso

Reputation: 3199

You call your code in onCreate() method and yes, it's wrong. If you check javaDoc for animationDrawable method start(), you will see you can't start in onCreate(), but you should call it in onWindowFocusChanged(boolean) method.

Upvotes: 1

Related Questions