我有一个存储在应用程序中的返回日期(接近某个地方)。
现在我需要找出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) );
}
}
这不能正常.....你们有什么想法吗?
答案 0 :(得分:0)
根据documentation,您需要从我正在阅读的内容中调用pct.start()。否则,我不是Android开发人员,但也有常规Java中的Timer类,并且看起来也可以在Android中使用。