android - using animatorSet.playTogether(Collection<Animator> items) in a function -


i've created function gets string. start loop runs through characters of string, , acts based on character switch (each character has different case).

public void setblimps(string locations){     final relativelayout game = (relativelayout) findviewbyid(r.id.relativelayout);     // getting layout     for(int = 0; < locations.length(); i++){         switch(locations.charat(i)){ 

^the beginning fo loop^

all cases quite similar, example:

            case 'a':                 final imageview blimpa = new imageview(this);                 blimpa.setimageresource(r.drawable.explosion);                 relativelayout.layoutparams layoutparamsa = new relativelayout.layoutparams(150,150);                 layoutparamsa.setmargins(200, 200, 200, 200);                 blimpa.setlayoutparams(layoutparamsa);                 blimpa.setpivotx(150);                 blimpa.setpivoty(150);                 runonuithread(new runnable() {                     @override                     public void run() {                         game.addview(blimpa);                     }                 });                 final objectanimator anima1 = objectanimator.offloat(blimpa,"translationx",0,-200).setduration(1000);                 final objectanimator anima2 = objectanimator.offloat(blimpa,"translationy",0,-200).setduration(1000);                 animators.add(anima1);                 animators.add(anima2);                 break; 

in each case want create imageview specific parameters : resource, pivotx/y, margins, etc (all cases can functionalized, it's bit complex). add relativelayout using runonuithread.

i create specific animators of imageview(property animation) , add them global arraylist called "animators".

    runonuithread(new runnable() {         @override         public void run() {             animatorset.playtogether(animators);// doesn't work         }     }); 

^this called upon exiting loop and, understood, should play animators i've given on specified imageviews @ same time. *the animatorset global

when give function string "ae" , run code succeeds in creating casea's imageview, doesn't play animations. in addition, not create casee imageview , doesn't play animations well.

*the function called in timertask (doesn't seem problem)

any making work or making more efficient appreciated!


Comments