倒计时原来都用handler+timer写,现在发现Android 已将封装好了一个类CountDownTimer

  public CountDownTimer startCount(Button button, int time) {        //由于CountDownTimer有一定的延迟,所以这里设置3400        CountDownTimer countDownTimer = new CountDownTimer(time + 400, 1000) {            @Override            public void onTick(long millisUntilFinished) {                button.setText("跳过(" + millisUntilFinished / 1000 + "s)");            }            @Override            public void onFinish() {                button.setText("跳过(" + 0 + "s)");                SplashPresenter.this.mvpView.countEnd();            }        }.start();        return countDownTimer;    }

cancle在onTick()中是不起作用的,所以可以在外面进行取消

更多相关文章

  1. 今天发现了一个不错的android加载动画
  2. Android performance今天的发现
  3. [Android应用开发]添加了两个Button后发现只显示一个
  4. Kotlin 风险高、RxJava 已过时,Android 原生开发现状分析!
  5. 归纳整理一些工作学习中发现的不错的网站、博客地址等
  6. 发现自己喜欢了移动端开发--Android
  7. 今天发现的一些优秀的资源网站
  8. Android 出错显示找不到id,但你发现id是存在的

随机推荐

  1. Android应用开机自启
  2. intent-filter
  3. android 下的内存状态获取
  4. 安卓如何关闭软键盘?
  5. cts android.hardware.camera2.cts.Recor
  6. Android----imageView实现图片的旋转和缩
  7. Android之背景圆角矩形
  8. radioButton 使用
  9. android listveiw 嵌套Girdview
  10. android开发笔记之viewpager 基本使用方