Thursday 6 June 2013

android AnimationDrawable stop

android AnimationDrawable stop
private void checkIfAnimationDone(AnimationDrawable anim){
            final AnimationDrawable a = anim;
            int timeBetweenChecks = 300;
            Handler h = new Handler();
            h.postDelayed(new Runnable(){
                public void run(){
                    if (a.getCurrent() != a.getFrame(a.getNumberOfFrames() - 1)){
                        checkIfAnimationDone(a);
                    } else{
                        Toast.makeText(getApplicationContext(), "ANIMATION DONE!", Toast.LENGTH_SHORT).show();
            
                    }
                }
            }, timeBetweenChecks);
    };

No comments:

Post a Comment