【发布时间】:2011-06-02 02:11:54
【问题描述】:
我有工作代码,但似乎有点奇怪,我不得不在 CountDownTimer 上显示小数位,但我没有找到任何更容易的方法(显然)。
这是我目前拥有的工作代码:
final String tempTitle = TextView.getText().toString();
new CountDownTimer(10000, 100) {
public void onTick(long millisUntilFinished) {
String timeDown = String.valueOf(millisUntilFinished / 100);
String secTime="0";
String sec10th="0";
if (Long.valueOf(millisUntilFinished) < 1000) {
secTime ="0";
sec10th = timeDown.substring(0,1);
}else{
secTime=timeDown.substring(0,1);
sec10th = timeDown.substring(1,2);
}
TextView.setText("Start in: " + secTime + "." + sec10th);
}
public void onFinish() {
TextView.setText(tempTitle);
}
}.start();
}
【问题讨论】:
标签: java android decimal long-integer countdown