2010-07-10 12 views
1

public void startGameButtonClicked (Voir la vue) { final TextView shadow = (TextView) findViewById (R.id.main_menu_start_game_button_shadow);Comment mettre en pause l'exécution du code jusqu'à la fin de l'animation

final Animation animation = AnimationUtils.loadAnimation(this, R.anim.main_menu); 
    shadow.startAnimation(animation); 

    /** Ugly prototype pausing */ 
    final long startTime = System.currentTimeMillis(); 
    while ((System.currentTimeMillis() - startTime) < 600) { 
     Log.i("test", Boolean.toString(animation.hasEnded())); 
    } 


    final Intent intent = new Intent(); 
    intent.putExtra(EXTRA_BUTTON_ID, START_GAME_BUTTON); 

    setResult(RESULT_OK, intent); 

    finish(); 
} 

Mon animation a une durée = 400, comment puis-je mettre en pause tout sauf l'animation après avoir appelé shadow.startAnimation (animation); ? Je demande becouse, comme vous pouvez le voir - animation est définie pour l'action de clic sur le bouton, ce qui tue l'activité actuelle, de sorte que l'animation n'est pas affichée complètement.

Répondre

1

Vous devez définir «suspendre tout» pour obtenir une réponse.

Ce que je vais proposer est de mettre en œuvre AnimationListener dans votre activité, et le diriger vers l'animation. Ensuite, dans onAnimationEnd(), appelez simplement finish().