Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 790
Hesam Avatar asked Oct 06 '11 02:10

Hesam


People also ask

How do I turn off infinite animation on Android?

Use clearAnimation() to stop an animation.

Is animation possible on Android?

On Android 4.4 (API level 19) and higher, you can use the transition framework to create animations when you swap the layout within the current activity or fragment. All you need to do is specify the starting and ending layout, and what type of animation you want to use.

What are animations on Android phones?

Android devices display animations when they transition between apps, windows, and various menus. Animations oftentimes looks slick, but they do take up time—and sometimes can even cause the phone to lag if it's low on resources.


1 Answers

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

    }
});
like image 81
Rahulkapil Avatar answered Sep 19 '22 17:09

Rahulkapil