Android Countdowntimer Countdown Timer Usage Example _android

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.