2011-02-16 124 views
3

我怎麼能停止動畫..this是我的代碼如何停止動畫

import android.app.Activity; 
import android.os.Bundle; 
import android.view.View; 
import android.view.animation.Animation; 
import android.view.animation.AnimationUtils; 
import android.widget.Button; 
import android.widget.ImageView; 

public class animation extends Activity { 

    ImageView img; 
    Animation an; 
    Button bt; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     img = (ImageView)findViewById(R.id.ImageView01); 
     an = AnimationUtils.loadAnimation(this, R.anim.anim); 
     bt= (Button)findViewById(R.id.Button01); 

     bt.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 
       img.startAnimation(an); 
      } 
     }); 
    } 
} 
+1

請花一些時間和格式化您的代碼! – WarrenFaith 2011-02-16 12:34:05

回答

7

我假設你的Animation(an)運行無限。當你想要停止使用img.clearAnimation();