I use this method to start any animation (resID of the animation XML).
If nextPuzzleOnEnd is true, the method "nextPuzzle" is called when the animation has finished.
The method is part of my puzzle-apps and I use it to display any success animation and afterwards (after anim has finished) continue with the next puzzle.
/*
* start animation (any view)
*/
private void startAnimation(View v, int resId, Boolean nextPuzzleOnEnd){
Animation anim;
if(v!=null){ // can be null, after change of orientation
anim = AnimationUtils.loadAnimation(this.getContext(),resId);
anim.setFillAfter(false);
v.setAnimation(anim);
if( nextPuzzleOnEnd ){
anim.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation anim)
{
};
public void onAnimationRepeat(Animation anim)
{
};
public void onAnimationEnd(Animation anim)
{
nextPuzzle();
};
});
}
v.startAnimation(anim);
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…