如何暂停在Android handler.postDelayed()计时器 [英] How to pause handler.postDelayed() timer on Android
本文介绍了如何暂停在Android handler.postDelayed()计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能暂停 handler.postDelayed()
定时器使用一个按钮。所以,当我点击该按钮再次 handler.postDelayed()
计时器应该恢复。
handler.postDelayed(counterz,60);
解决方案
处理程序
没有一个定时器来调整。您张贴到一个线程,那里有很多其他的东西也运行正常的事件队列中。
您可以取消发布的Runnable
的:
handler.removeCallbacks(counterz);
和再次发布,恢复。
How can i pause the handler.postDelayed()
timer using a button. So when i click the same button again the handler.postDelayed()
timer should resume.
handler.postDelayed(counterz, 60);
解决方案
Handler
does not have a timer to tweak. You are posting to event-queue of a thread, where a lot of other stuff is running as well.
You can cancel posted Runnable
's:
handler.removeCallbacks(counterz);
And post again, to resume.
这篇关于如何暂停在Android handler.postDelayed()计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文