2012-10-10 3 views
0

Je veux créer une sorte d'imageGallery avec deux animations différentes. Lorsque vous cliquez sur l'image actuellement visible, une "OK-Image" doit apparaître (1 seconde, non répétée), une fois l'animation terminée, l'image suivante doit être affichéeAndroid AnimationListener ne se fait pas frapper

Chaque image a une animation infinie et répétée (vue normale, vue zoomée)

so ..

  • Étape 1: Infinite animation d'une image (normal => zoom => normale ..)
  • Étape 2: Cliquez sur
  • Étape 3 : Afficher "OK-Image" (fondu en 1 sec)
  • Étape 1 ...

Le problème est que l'animation Listener du OK-animation est touché, le Animationlistener de l'animation infinie ne ..

@Override 
public void onCreate(Bundle savedInstanceState) { 
    fadeInOKAnimation = AnimationUtils.loadAnimation(this, R.anim.fadeinonce); 
    fadePermanentAnimation = AnimationUtils.loadAnimation(this, R.anim.fadeininfinite); 
    fadeInOKAnimation.setAnimationListener(fadeInOKAnimationListener);   
    fadePermanentAnimation.setAnimationListener(fadePermanentAnimationListener); 
} 


AnimationListener fadeInOKAnimationListener = new Animation.AnimationListener() { 

    public void onAnimationEnd(Animation animation) 
    { 
     ThreadHelper.sleep(500); 
     imgMessung.clearAnimation(); 
     int currentImageId = currentStateImage.getNormalImage(); 
     imgMessung.clearAnimation(); 
     imgMessung.setImageResource(currentImageId); 
     imgMessung.startAnimation(fadePermanentAnimation); 
    } 

    public void onAnimationRepeat(Animation animation) { } 

    public void onAnimationStart(Animation animation) { } 
}; 


AnimationListener fadePermanentAnimationListener = new Animation.AnimationListener() { 

    public void onAnimationEnd(Animation animation) { } 

    public void onAnimationRepeat(Animation animation) { 

     StateImage currentStateImage = messung.GetCurrentImage(); 

     if(currentImageState == ImageState.Normal) 
     { 
     int currentImageId = Integer.parseInt(currentStateImage.getNormalImage()); 
     imgMessung.setImageResource(currentImageId); 
     } 
     else 
     { 
     int currentImageId = Integer.parseInt(currentStateImage.getZoomedImage()); 
     imgMessung.setImageResource(currentImageId); 
     } 
    } 

    public void onAnimationStart(Animation animation) { } 

}; 

Répondre

0

Il n'y a pas fin pour l'animation sans fin, donc rien ne sera déclenché. Vous pouvez utiliser onAnimationRepeat pour savoir où l'animation est redémarrée (mais alors - ce dont vous avez besoin de répétition sans fin? Si vous avez besoin de quelques éléments pour animer sans fin (c.-à-d. Marqueur occupé), enveloppez-le FrameLayout et plantez votre animation et écoute là

+0

J'utilise déjà onAnimationRepeat pour l'animation fadePermanentAnimationListener .. mais cela ne me touche pas – Roland85

Questions connexes