1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| // mhandle.postDelayed(timeRunable , 1000);调用 切勿重复调用 //currentSecond =0;重置时间 /*****************计时器*******************/ private Runnable timeRunable = new Runnable() { @Override public void run() { currentSecond = currentSecond + 1000; timerText.setText(TimeUtil.getFormatHMS(currentSecond)); if (!isPause) { //递归调用本runable对象,实现每隔一秒一次执行任务 mhandle.postDelayed(this, 1000); } } }; //计时器 private Handler mhandle = new Handler(); private boolean isPause = false;//是否暂停 private long currentSecond = 0;//当前毫秒数
|