有时我们需要在代码运行之前延迟它.
这可以通过Handler.postDelayed(Runnable)或CountdownTimer来实现.
Which one is better in terms of performance?
请参阅下面的示例代码
处理器
new Handler().postDelayed(new Runnable() { @Override public void run() { //DO SOMETHING } },1000);
倒计时器
new CountDownTimer(1000,1000) { public void onFinish() { //DO SOMETHING } public void onTick(long millisUntilFinished) {} }.start();