国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

CountdownTimer倒計(jì)時(shí)詳解

2019-11-09 17:38:24
字體:
供稿:網(wǎng)友
一.類描述    定時(shí)執(zhí)行在一段時(shí)候后停止的倒計(jì)時(shí),在倒計(jì)時(shí)執(zhí)行過程中會(huì)在固定間隔時(shí)間得到通知(觸發(fā)onTick方法),

下面的例子顯示在一個(gè)文本框中顯示一個(gè)3s,間隔時(shí)間為1s的倒計(jì)時(shí):

CountDownTimer countTimer = new CountDownTimer(3000, 1000) {    @Override    public void onTick(long millisUntilFinished) {        tx_time.setText((millisUntilFinished / 1000 + 1) + "");    }    @Override    public void onFinish() {        tx_time.setText(1 + "");        finish();        //執(zhí)行其他邏輯    }};

二.源碼分析

構(gòu)造方法:

public CountDownTimer(long millisInFuture, long countDownInterval) {    mMillisInFuture = millisInFuture;    mCountdownInterval = countDownInterval;}

millisInFuture 表示的是總時(shí)間,countDownInterval 表示的是時(shí)間間隔

公共方法:

/** * 開啟倒計(jì)時(shí). */public synchronized final CountDownTimer start() {    、、    return this;}

/** * 取消倒計(jì)時(shí). */public synchronized final void cancel() {    、、}

/** * 固定時(shí)間間隔會(huì)調(diào)用此方法 , millisUntilFinished 為倒計(jì)時(shí)剩余時(shí)間
 * @param millisUntilFinished The amount of time until finished. */public abstract void onTick(long millisUntilFinished);

/** * 計(jì)時(shí)器結(jié)束時(shí)調(diào)用. */public abstract void onFinish();


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 临城县| 库尔勒市| 乌兰浩特市| 贵南县| 岫岩| 杂多县| 大兴区| 达日县| 聂拉木县| 饶阳县| 台山市| 蚌埠市| 宜章县| 舒城县| 莒南县| 嘉定区| 阿鲁科尔沁旗| 清水县| 隆安县| 丹阳市| 科技| 溆浦县| 阿勒泰市| 浦东新区| 崇信县| 孝感市| 广东省| 政和县| 临湘市| 台安县| 东城区| 呈贡县| 昭通市| 玉环县| 城步| 文安县| 中山市| 光山县| 武功县| 西安市| 邛崃市|