在进度条上设置特定的重复次数

时间:2019-03-03 02:06:49

标签: java android mobile progress-bar countdowntimer

我想将我的两个进度条重复13次。我猜for循环是否可以解决此问题。进度条的10秒钟开始运行后,重置按钮或停止按钮也不起作用。这是我的倒数计时器代码

    private void startCountDownTimer() {
        timeCountInMilliSeconds = 30 * 1000;
        countDownTimer = new CountDownTimer(timeCountInMilliSeconds, 1000) {
        @Override
        public void onTick(long millisUntilFinished) {
            textViewTime.setText(hmsTimeFormatter(millisUntilFinished));
            progressBarCircle.setProgress((int) (millisUntilFinished / 1000));
        }
        @Override
        public void onFinish() {
            textViewTime.setText(hmsTimeFormatte(timeCountInMilliSeconds));
            setProgressBarValues();
            imageViewReset.setVisibility(View.GONE);
            imageViewStartStop.setImageResource(R.drawable.icon_start);
            timerStatus = TimerStatus.STOPPED;
            tenseconds();
        }
    }.start();
    countDownTimer.start();
}
private void tenseconds(){
timeCountInMilliSeconds = 10 * 1000;
countDownTimer = new CountDownTimer(timeCountInMilliSeconds, 1000) {
    @Override
    public void onTick(long millisUntilFinished) {
        textViewTime.setText(hmsTimeFormatter(millisUntilFinished));
        progressBarCircle.setProgress((int) (millisUntilFinished / 1000));
    }
    @Override
    public void onFinish() {
        textViewTime.setText(hmsTimeFormatter(timeCountInMilliSeconds));
        setProgressBarValues();
        imageViewReset.setVisibility(View.GONE);
        imageViewStartStop.setImageResource(R.drawable.icon_start);
        timerStatus = TimerStatus.STOPPED;
        startCountDownTimer();
    }
}.start();
countDownTimer.start();
}

0 个答案:

没有答案