Android, How do I know that the animation is finished?

In my project, I have a button. when the user clicks on it, he also shows the animation, after which he must load another action.

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

according to the code above (startActivity, commented), when I launch the application and press the button, the animation will play. but if I uncomment it due to a quick transition, the animation is not displayed. How can I report that the animation is finished? Thanks

+6
source share
1 answer

This code is called in your animation object:

 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 } }); 
+9
source

Source: https://habr.com/ru/post/898723/


All Articles