http://blog.csdn.net/freesonhp/article/details/25904047
In peacetime when we program, 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 discovered, let's share it:
The remaining time is constantly shown in a TextView code as follows:
[Java]View Plaincopy
- Private TextView Vertifyview;
- private Countdowntimer timer = new Countdowntimer (10000, + ) {
- @Override
- public void OnTick (long millisuntilfinished) {
- Vertifyview.settext ((millisuntilfinished/ +) + "Second can be re-sent");
- }
- @Override
- public void OnFinish () {
- Vertifyview.setenabled (true);
- Vertifyview.settext ("Get Verification Code");
- }
- };
The call is simple: Timer.start ();
The final explanation: Countdowntimer timer = new Countdowntimer (10000, 1000), the first parameter represents the total time, and the second parameter represents the time interval. This means that the method Ontick is called back every second, and then the OnFinish method is recalled after 10 seconds.
The use of the Android Countdowntimer countdown timer