动画Drawable结局

时间:2013-12-12 15:12:09

标签: android animation

我有这个动画可绘制的运行,我想只在它完成时继续。此代码导致图像重叠。

public void onClick(View w) {
        rangen = r.nextInt(4-1)+1;
        frameAnimation.start();

        if (rangen==1){
            enemyj.setImageResource(R.drawable.paper);
            restextj.setText("You Lose!");}
        else if (rangen==2){
            enemyj.setImageResource(R.drawable.rock);
            restextj.setText("Draw");}
        else if (rangen==3){
            enemyj.setImageResource(R.drawable.sciss);
            restextj.setText("You Win!");}}
        }

1 个答案:

答案 0 :(得分:0)

在启动之前为frameAnimation添加动画侦听器

frameAnimation.setAnimationListener( new AnimationListener() {

    @Override
    public void onAnimationEnd (Animation animation) {
        animation.setAnimationListener(null);
        //do whatever work you need done 
    }

    @Override
    public void onAnimationRepeat (Animation animation) {
    }

    @Override
    public void onAnimationStart (Animation animation) {
    }
});