一段时间后使用沙漏刻度功能,TextView停止更新

时间:2018-12-12 12:51:37

标签: java android android-studio hourglass

//运行几分钟后,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);

    }

0 个答案:

没有答案