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.