我在应用程序中存储了一个返回日期(在不久的将来)。
现在我需要知道android手机的当前时间,然后我就可以知道倒计时的分钟数了。下面是我目前所拥有的,当我创建下面的对象时,我传递给它PinnedCountdownTimer pct = new PinnedCountdownTimer((getTimeToReturn().getTime()-System.currentTimeMillis()),1000,countdownTv);
public class PinnedCountdownTimer extends CountDownTimer {
TextView tv;
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
Date resultdate ;
public PinnedCountdownTimer(long millisInFuture, long countDownInterval,TextView tv) {
super(millisInFuture, countDownInterval);
this.tv = tv;
}
@Override
public void onFinish() {
tv.setText("get back to your car!");
}
@Override
public void onTick(long millisUntilFinished) {
resultdate = new Date(millisUntilFinished);
tv.setText("Left: " + sdf.format(resultdate) );
}}
这是不工作的correctly.....do你们有什么想法吗?
发布于 2011-07-08 00:19:02
根据documentation,您需要根据我正在阅读的内容调用pct.start()。另外,我不是一个安卓开发人员,但是还有一个Timer类,它是用普通的Java语言编写的,看起来在安卓系统中也是可用的。
https://stackoverflow.com/questions/6613538
复制相似问题