Custom flashing text for Android

Source: Internet
Author: User

Custom flashing text, direct code to engage:

Package Custom.text.view;import Java.util.timer;import Java.util.timertask;import android.content.context;import Android.graphics.color;import Android.os.handler;import Android.os.message;import Android.util.AttributeSet; Import Android.util.log;import android.widget.textview;/*** * @author TIANBX * @version 1.0 * Blinking text * */public class Flick Ertextview extends TextView {private static final String Log_tag = "Flickertextview"; Boolean change = False;private Handle R handler = Null;public Flickertextview (context context, AttributeSet attrs, int defstyle) {Super (context, Attrs, Defstyle ); LOG.E (Log_tag, "super (context, Attrs, Defstyle)"); Startflicker ();//TODO auto-generated constructor Stub}public Flickertextview (context context, AttributeSet Attrs) {Super (context, attrs); Startflicker (); LOG.E (Log_tag, "super (context, attrs)");//TODO auto-generated Constructor Stub}public Flickertextview (Context context ) {super (context); Startflicker (); LOG.E (Log_tag, "flickertextview (context context)");} Public void Startflicker () {handler = new handler () {@Overridepublic void DispatchMessage (Message msg) {if (change) {change = Fals E;settextcolor (color.transparent); This is transparent, = Cannot see the text}else{change = True;settextcolor (color.red);}}; Timer timer = new timer (); TimerTask task = new TimerTask () {@Overridepublic void run () {message msg = new Message (); Handler.sendmessage (msg);}};  Timer.schedule (task,1,300); Parameters are delay (how long after execution), duration (execution interval)}}



Explanation: It is important to start a timed task and execute the thread.



Related Article

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.