//运行几分钟后,UI停止在tick函数内部更新。 //以下是我的文本视图的更新功能
private void timerGreen(final long time, long interval) {
hourglassGreen = new Hourglass(time, interval) {
@Override
public void onTimerTick(long timeRemaining) {
updateUIGreen(timeRemaining);
if (soundrunning) {
soundTick = new SoundTick();
soundTick.playSound(MainActivity.this);
}
}
@Override
public void onTimerFinish() {
}
};
}
// here it is my textview call in my function
private void updateUIGreen(long timeRemain) {
greenTextView.setText(correctFormat(timeRemain));
}
///这里是我的correctFormat方法 公共字符串CorrectFormat(long millisUntilFinished){
int minutes = (int) (millisUntilFinished / 1000) / 60;
int secs = (int) (millisUntilFinished / 1000) % 60;
return String.format(Locale.getDefault(), "%02d:%02d", minutes, secs);
}