android animationlistener loop

a következőt ne csináljuk, mert végtelen ciklusba fogunk lépni
don’t do this if you don’t want az infinite loop

SomeViewSubclass view = new SomeViewSubclass(this);
view.animate().alpha(0f).setDuration(1000).setListener(new Animator.AnimatorListener() {

   /* 
   the other 3 method of the AnimatorListener interface 
   a másik 3 AnimatorListener interface függvény
   */

   @Override
   public void onAnimationEnd(Animator animator) {
      /*
          do something you want
      */
      view.animate().alpha(1f).setDuration(1000);
   }

});

Mindenképpen kell egy setListener(null) hívás a második animálás végére, különben mindig be fogunk esni az onAnimationEnd függvénybe
You have to call a setListener(null) on the end of the expression, if you don’t, your onAnimationEnd function will be called forever

SomeViewSubclass view = new SomeViewSubclass(this);
view.animate().alpha(0f).setDuration(1000).setListener(new Animator.AnimatorListener() {

   /* 
   the other 3 method of the AnimatorListener interface 
   a másik 3 AnimatorListener interface függvény 
   */

   @Override
   public void onAnimationEnd(Animator animator) {
      /*
          do something you want
      */
      view.animate().alpha(1f).setDuration(1000).setListener(null);
   }

});

Hozzászólás