1、定时器
- TimerTask task = new TimerTask()
- {
- public void run()
- {
- //逻辑
- }
- };
- Timer timer = new Timer();
- timer.schedule(task, 500);//延时0.5秒
2、消息
- new Handler().postDelayed(new Runnable()
- {
- public void run()
- {
- //逻辑
- }
- }, 500);//延时0.5秒
try
{
Thread thread = Thread.currentThread();
thread.sleep(500);//延时0.5秒
}
catch (InterruptedException e)
{
e.printStackTrace();
}