2014-09-15 2 views
0

Dans mon activité, j'ai une méthode qui doit répéter jusqu'à ce que l'utilisateur clique sur un boutonAndroid: Méthode looper

private void AnimateItem(int i){ 
     ((AnimationDrawable) myList.getChildAt(i).getBackground()).start(); 
     } 

    private void CheckItems(){ 
    int[] items = new int[]{1,3,5}; 
    for(int i = 0; i<items.length(); i++){ 
    AnimateItem(i); 
    } 
} 

Donc, ici je vais avoir:

AnimateItem(1); 

AnimateItem(3); 

AnimateItem(5); 

Comment exécuter les méthodes une à une (quand le 1er a été terminé, commencez le 2ème ... et répétez le cycle après la fin de la dernière méthode) jusqu'à ce que le bouton soit cliqué.

Répondre

0

lieu sur la méthode AnimateItem (i) de la vôtre, si votre activité met en œuvre AnimationListener nous pouvons plus monter les méthodes suivantes

@Override 
public void onAnimationStart(Animation animation) { 
    // TODO Auto-generated method stub 

} 

@Override 
public void onAnimationEnd(Animation animation) { 
    // TODO Auto-generated method stub 
    if (animation == your desired Animation) { 
     //start your new Animation 
    } 
} 

@Override 
public void onAnimationRepeat(Animation animation) { 
    // TODO Auto-generated method stub 

} 
+0

Voici pas pour AnimationDrawable Listeners –

Questions connexes