2016-12-11 1 views
1

Je veux montrer l'animation dans mon application, et je veux montrer cette animation chaque 3000m/s.
J'écris ci-dessous le code, mais dans ce code montre une seule fois.Comment faire pour exécuter le code à chaque fois dans Android

new Handler().postDelayed(new Runnable() { 
    @Override 
    public void run() { 
     YoYo.with(Techniques.Bounce) 
       .duration(1500) 
       .playOn(arrowHelpImage); 
    } 
}, 3000); 

Comment puis-je modifier mon code et afficher chaque 3000m/s?

Répondre

0

U pourrait utiliser quelque chose comme ceci. changez les animations utilisées ci-dessous. ces animations vont s'exécuter à l'infini. fournir une animation à la fin Listner. Changer la durée de l'animation à 3000ms et l'utiliser dans handler.it fonctionnera

YoYo.with(Techniques.Bounce) 
    .duration(1200) 
    .interpolate(new AccelerateDecelerateInterpolator()) 
    .withListener(new Animator.AnimatorListener() { 

     @Override 
     public void onAnimationStart(Animator animation) {} 

     @Override 
     public void onAnimationEnd(Animator animation) { 
      YoYo.with(Techniques.Bounce) 
      .duration(1200) 
      .interpolate(new AccelerateDecelerateInterpolator()) 
      .withListener(this).playOn(arrowHelpImage); 
     } 

     @Override 
     public void onAnimationCancel(Animator animation) {} 

     @Override 
     public void onAnimationRepeat(Animator animation) {} 
    }).playOn(arrowHelpImage); 
+0

merci mon ami <3 –

0

Mettez le code ci-dessous dans votre cours.

private Handler handler; 
private Runnable runnable; 

ci-dessous le code en vous onCreate

handler = new Handler(); 
     runnable = new Runnable() { 
      @Override 
      public void run() { 


YoYo.with(Techniques.Bounce) 
       .duration(1500) 
       .playOn(arrowHelpImage); 
       handler.postDelayed(runnable, Constants.SPLASH_DURATION); 
      } 
     }; 
     handler.postDelayed(runnable, Constants.SPLASH_DURATION); 


@Override 
protected void onDestroy() { 
    super.onDestroy(); 
    //Close the handler and the process of splash screen. 
    if (handler != null && runnable != null) { 
     handler.removeCallbacks(runnable); 
    } 
}