码迷,mamicode.com
首页 > 其他好文 > 详细

定时器

时间:2015-01-20 15:35:45      阅读:187      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!