2012-07-11 164 views
0

嗨,我有一個動畫,我想延遲一個runnable的啓動,但是它的原因動畫循環,我不需要我只是希望它延遲,然後運行曾經有人知道如何?Android只能運行一次運行

繼承人我的代碼

public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.layout_initialsetup); 
     handler = new Handler(); 
     final Runnable r = new Runnable() 
     { 
      public void run() 
      { 
       animations(); 
       handler.postDelayed(this, 1000); 
      } 
     }; 
     handler.postDelayed(r, 1000); 
    } 


    public void animations(){ 
     image = (ImageView)findViewById(R.id.su_shirts); 
     AnimationMovepos = AnimationUtils.loadAnimation(this, R.anim.shirt_anim); 
     image.startAnimation(AnimationMovepos); 
    } 
} 

回答

6

這是您再次發佈它與該呼叫的處理程序可運行的內循環,因爲:

handler.postDelayed(this, 1000); 

刪除,並不會循環

+0

謝謝你,這是正確的,我不能接受10分鐘,但會做什麼時,我可以 – 2012-07-11 13:22:18

+5

10很長的時間... – 2013-06-03 11:30:36

+3

他太靠近黑洞。 – 2015-01-22 20:56:17

2

嘗試在您的run()方法中刪除handler.postDelayed(this, 1000);