倒计时代码

 1 new CountDownTimer(30000, 1000) {
 2 
 3             @Override
 4             public void onTick(long millisUntilFinished) {
 5                 // TODO Auto-generated method stub
 6 
 7                 // System.out.println(millisUntilFinished / 1000 % 60 + "秒");
 8                 // System.out.println(millisUntilFinished / 1000 / 60 % 60 +
 9                 // "分");
10                 // System.out.println(millisUntilFinished / 1000 / 60 / 60 +
11                 // "小时"
12                 // + millisUntilFinished / 1000 / 60 % 60 + "分"
13                 // + millisUntilFinished / 1000 % 60 + "秒");
14 
15                 String hours = millisUntilFinished / 1000 / 60 / 60 + "小时";
16                 String min = millisUntilFinished / 1000 / 60 % 60 + "分";
17                 String sec = millisUntilFinished / 1000 % 60 + "秒";
18 
19                 tv.setText(hours + min + sec);
20             }
21 
22             @Override
23             public void onFinish() {
24                 // TODO Auto-generated method stub
25                 tv.setText("finishi");
26             }
27         }.start();

 

posted @ 2013-12-16 19:52  莲花味精  阅读(290)  评论(0编辑  收藏  举报