列表中倒计时实现

    一些活动列表每个item都需要加载倒计时,大致思路是:

倒计时是功能 利用 CountDownTimer 写倒计时 参考链接: android CountDownTimer 计时器,然后将CountDownTimer 设置为需要显示倒计时的控件上,创建之前先判断是否存在。

TextView countDown;
if(countDown.getTag != null){
   CountDownTimer countDownTimer = new CountDownTimer(10000, 1000) {
        @Override public void onTick(long millisUntilFinished) {
          //每秒倒计时返回
        }

        @Override public void onFinish() {
          //计时器结束
        }
      };
    countDownTimer.start();
    countDown.setTag(countDownTimer);
}

猜你喜欢

转载自blog.csdn.net/ff_hh/article/details/81060189
今日推荐