国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 宜川县| 建瓯市| 瓦房店市| 囊谦县| 汽车| 奎屯市| 丹东市| 纳雍县| 深泽县| 文登市| 鸡东县| 务川| 财经| 阿尔山市| 驻马店市| 普宁市| 青海省| 博罗县| 东乌| 克山县| 陕西省| 三门峡市| 仙游县| 孙吴县| 中牟县| 灌阳县| 福建省| 当阳市| 礼泉县| 昭苏县| 宜良县| 巩留县| 天全县| 黑河市| 阜平县| 朝阳县| 扬州市| 扎兰屯市| 孟州市| 乐都县| 礼泉县|