This example describes the use of Countdowntimer countdown in Android. Share to everyone for your reference, specific as follows:
In peacetime we are programmed, often use the countdown to this function, many people do not know that Android has helped encapsulate a class, often write their own. Now that this class has been found, we share it:
In a TextView continuously display the remaining time, the code is as follows:
Private TextView Vertifyview;
Private Countdowntimer timer = new Countdowntimer (10000, 1000) {
@Override public
void Ontick (long millisuntilfinished) {
Vertifyview.settext (millisuntilfinished/1000) + "can be sent back after seconds");
}
@Override public
void OnFinish () {
vertifyview.setenabled (true);
Vertifyview.settext ("Get Authentication Code");
}
;
It's simple to call:
Copy Code code as follows:
Timer.start ();
Finally, explain:
Countdowntimer timer = new Countdowntimer (10000, 1000), the first parameter represents the total time, and the second parameter represents the interval time. This means that the method Ontick is recalled every second, and then the OnFinish method is recalled after 10 seconds.
I hope this article will help you with the Android program.