android 计时器线程

private Handler handler = new Handler( );

private Runnable runnable = new Runnable( ) {

public void run ( ) {

update( );// 要运行的方法

handler.postDelayed(this,1000);     //postDelayed(this,1000)方法安排一个Runnable对象到主线程队列

}

};

handler.postDelayed(runnable,1000);         // 开始Timer

handler.removeCallbacks(runnable);           //停止Timer


你可能感兴趣的:(android,timer,android计时器,androidTimer)