0

In my Activity I've a Method which must repeat until the user clicks on a button

   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);
    }
}

So, here I'll have:

AnimateItem(1);

 AnimateItem(3);

 AnimateItem(5);

How to execute methods one by one (when 1st was ended, start 2nd... and repeating cycle after last method end) until button was clicked.

CocoNess
  • 4,213
  • 4
  • 26
  • 43
Nicu Ro
  • 33
  • 4

1 Answers1

0

Instead on AnimateItem(i) method of yours, if your activity implements AnimationListener we can over ride following methods

@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

}
Sid
  • 691
  • 6
  • 9