7

In my project i have a button. when user clicks on it, it shows and animation after that should load another activity.

@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 above code(startActivity, commented), when I run the application and click on the button, animation will play. but if i uncomment it because of fast transition animation doesn't show. How can i inform that animation is finished? Thanks

Hesam
  • 49,622
  • 70
  • 212
  • 354

1 Answers1

15

On your animation object call this code:

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

    }
});
Thomas Vos
  • 11,770
  • 4
  • 29
  • 70
Rahulkapil
  • 294
  • 4
  • 13