2011-10-06 25 views
6

En mi proyecto tengo un botón. cuando el usuario hace clic en él, se muestra y la animación después de eso debe cargar otra actividad.Android, ¿Cómo puedo saber que la animación ha finalizado?

@Override 
    public void onClick(View v) { 
     switch (v.getId()){ 
      case R.id.btnReadPage: 
       startAnimation(); 
       //stopAnimation(); 
       //Toast.makeText(this, "Read Page Clicked", Toast.LENGTH_SHORT).show(); 
       //startActivity(new Intent(this, ReadPage.class)); 
       return; 
     } 

    } 

acuerdo con el código de seguridad (startActivity, comentó), cuando corro la aplicación y haga clic en el botón, la animación se reproducirá. pero si lo descomente debido a la animación de transición rápida no se muestra. ¿Cómo puedo informar que la animación ha terminado? Gracias

+0

http://stackoverflow.com/questions/4750939/android-animation-is-not-finished-in-onanimationend –

+0

Salida la respuesta aquí. http://stackoverflow.com/questions/2214735/android-animationdrawable-and-knowing-when-animation-ends – pierrotlefou

+0

buena pregunta :) –

Respuesta

9

En su llamada objeto de animación de este código:

am1.setAnimationListener(new AnimationListener() {  
    @Override 
    public void onAnimationStart(Animation animation) { 
     // TODO Auto-generated method stub 
    } 

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

    @Override 
    public void onAnimationEnd(Animation animation) { 
     // Pass the Intent to switch to other Activity 

    } 
}); 
Cuestiones relacionadas