2012-07-11 166 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);