android 天数计时器,在android中使用倒计时器显示天数小时分秒的倒计时问题

我在我的应用程序中使用倒数计时器,我需要显示即将到来的日期,以天数小时,分钟和秒为单位。我得到了天,小时,分钟和秒,但是当我将其设置为文本视图时,倒计时无法启动。以下是我的代码。

Date date = new Date(2013,Integer.parseInt(datess.get(k).split("-")[1])-1,Integer.parseInt(datess.get(k).split("-")[0]),hours,mins,secs);

long dtMili = System.currentTimeMillis();

Date dateNow = new Date(dtMili);

remain = date.getTime() - dateNow.getTime();

MyCount counter = new MyCount(remain,1000);

counter.start();

public class MyCount extends CountDownTimer{

public MyCount(long millisInFuture, long countDownInterval) {

super(millisInFuture, countDownInterval);

}

@Override

public void onFinish() {

// TODO Auto-generated method stub

tv3.setText("done");

}

@Override

public void onTick(long millisUntilFinished) {

// TODO Auto-generated method stub

tv3.setText(timeCalculate(millisUntilFinished/1000) + " Countdown");

}

}

public String timeCalculate(long ttime)

{

long daysuuu,hoursuuu, minutesuuu, secondsuuu;

String daysT = "", restT = "";

daysuuu = (Math.round(ttime) / 86400);

hoursuuu = (Math.round(ttime) / 3600) - (daysuuu * 24);

minutesuuu = (Math.round(ttime) / 60) - (daysuuu * 1440) - (hoursuuu * 60);

secondsuuu = Math.round(ttime) % 60;

if(daysuuu==1) daysT = String.format("%d day ", daysuuu);

if(daysuuu>1) daysT = String.format("%d days ", daysuuu);

restT = String.format("%02d:%02d:%02d", hoursuuu, minutesuuu, secondsuuu);

return daysT + restT;

}

这是输出

QRYSo.png

为什么倒计时没有开始?任何建议都表示赞赏。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值