Get Verification Code countdown tool used when registering

Source: Internet
Author: User

In this construction method you need to pass in three parameters, one is activity, the other is the total time millisinfuture,
One is the time of each reduction, the last one is the countdown button
Usage:
Timelastutil new Timelastutil (btn);
Timelastutil.start ();


Tool class:
public class TimelastutilExtends Countdowntimer {

Private Activitymactivity;
Private TextViewBtnButton

In this construction method you need to pass in three parameters, one is activity, the other is the total time millisinfuture,
One is Countdowninterval, and then you do this on which button, you can just pass this button over.
Public Timelastutil (Activity mactivity,Long Millisinfuture,
Long Countdowninterval, TextView btn) {
Super (Millisinfuture, countdowninterval);
This.mactivity = mactivity;
This.BTN = BTN;
}



@SuppressLint ("Newapi")
@Override
public void OnFinish () {
Btn.settext (r.string.Register_regetchecknum);
Btn.setclickable (true);Get a click again
Btn.setbackgroundcolor (Color.Parsecolor ("#00CCCC"));Restore background color
}

@Override
public void OnTick (Long millisuntilfinished) {
Btn.setclickable (FALSE);Settings cannot be clicked
Btn.settext (millisuntilfinished/1000 +"s can be re-sent after");Set the countdown time

The Set button is grayed out and is not clickable at this time
Btn.setbackgroundcolor (Color.new spannablestring (btn.gettext (). toString ()); //gets the text of the button
Span.setspan (new Foregroundcolorspan (Color.red), 0, 2,
Spannable.span_inclusive_exclusive); //The countdown time is shown in red
btn.settext (span);

}

}

Get Verification Code countdown tool used when registering

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.