多语言展示
当前在线:1172今日阅读:84今日分享:32

android CountDownTimer 在列表里怎么使用

android CountDownTimer 在列表里怎么使用
工具/原料

android

方法/步骤
1

1.CountDownTimer 直接 new 出来使用,其构造函数

2

2.1.参数 - millisInFuture:设置倒计时的总时间(毫秒) 2.参数 - countDownInterval:设置每次减去的时间(毫秒)

3

3.1.cancel() 取消当前任务 2.onFinish() 当前任务完成的时候调用 3.onTick(long millisUntilFinished) 当前任务每完成一次倒计时间隔时间时回调 4.start() 开始当前的任务

4

4.Log

5

5.在CountDownTimer的onTick方法中记得对当前对象做判空处理 activity

6

6.在使用CountDownTimer时,在Activity或fragment生命周期结束时,调用timer.cancle()方法

推荐信息