首页 > 其他 > 详细

定时器

时间:2015-01-20 15:33:36      阅读:230      评论:0      收藏:0      [点我收藏+]

1  , handler.postDelayed  定时

        timerCount = Integer.parseInt(timer_tv.getText().toString());   //    页面上10秒 倒数
        handler = new Handler();
        // 开启 定时器
        handler.postDelayed(runnable, 1000);    // 1秒发送一次
---------------------------------------------------- Runnable runnable
= new Runnable() { private boolean isStop = false; // 停止标志位 @Override public void run() {
//------------业务处理 Toast.makeText(JpushNotifyordersActivity.
this, "定时器运行中", 300) .show(); timerCount--; if (timerCount == 0) { timerCount = 10; isStop = true; // 停止发送 // handler.removeCallbacks(runnable); //停止的方法// 请求网络 finish(); } timer_tv.setText("" + timerCount); if (!isStop) { // handler.postDelayed(this, 1000); //重复发送 } } };

 

定时器

原文:http://www.cnblogs.com/java-g/p/4236013.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!