How to use the chronometer as a countdown timer in Android

temre

I have defined a chronometer;

protected Chronometer chrono;
protected int baseTime;
protected int stopTime;
protected long elapsedTime;

My program asks questions to the user and i want to set a timer based on the user's input. I want a timer which starts at 10 to 0. How can i do that?

Also, I want to show the remaining time on the screen.

Shree Krishna

Use CountDownTImer instead,

 new CountDownTimer(10000, 1000) { //Sets 10 second remaining

 public void onTick(long millisUntilFinished) {
     mTextView.setText("seconds remaining: " + millisUntilFinished / 1000);
 }

 public void onFinish() {
     mTextView.setText("done!");
 }
}.start();

Note : It's not possible to start Chronometer reversely because the Chronometer widget only counts up.

Edit: From API level 24, it is possible to perform count down using chronometer via help of Chronometer#setCountDown(true) method.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

android how to use calender with countdown timer in adapter class?

From Dev

Android How to Change countdown Timer values at runtime

From Dev

Android Dialog with CountDown TImer

From Dev

Android ProgressBar timer countdown

From Dev

Android Dialog with CountDown TImer

From Dev

Faster Countdown timer in android

From Dev

Resuming Android countdown timer

From Dev

How to add a countdown timer

From Dev

How to use UIDatePicker (countdown timer) to select 0 hour 0 minute?

From Dev

How to use a countdown timer to stop a game - iOS [SWIFT] -

From Dev

Javascript countdown timer with multiple use

From Dev

How to Sync countdown timer with Server from Android Application

From Dev

Android - Properly creating and countdown of timer?

From Dev

Android User input to countdown timer

From Dev

How to create a "countdown timer" GIF?

From Dev

How to autostart a JavaScript Countdown Timer

From Dev

How to create an advanced countdown timer

From Dev

How can I countdown a timer

From Dev

how to countdown timer run in reactnative

From Dev

How to add text on countdown timer

From Dev

How to contain value of android chronometer with change in orientation

From Dev

How to parse values from chronometer (android)?

From Dev

Use JS countdown timer in Canvas with requestAnimationFrame

From Dev

Super simple js Countdown timer on android?

From Dev

Multiple Countdown Timer in Expandable Listview Android not working

From Dev

Setting a countdown timer with time picker dialog android

From Dev

set different times android countdown timer

From Dev

android countdown timer cancel vs timeup

From Dev

Super simple js Countdown timer on android?

Related Related

HotTag

Archive