Online Search a lot of blog read is not exhaustive, each method of the use of the meaning of writing are not all, even the method of eight bad, so I also thick cheek to write down this effect bar.
Because this page uses MVP, so there will be a iview accumulation, this method naturally will @override
@Override public void Setbluetext (string zw_longtext, String zw_bluetext) {//"to become a unicom user, the default speed can be raised free of charge to 200k/s, and the validity period is longer! Click on the Unicom User registration page to apply "; Remindlongwords = Zw_longtext + "click-through" + Zw_bluetext + "apply";//Display all strings//Draw Color Part code/* Spannablestringbuilde R style = new Spannablestringbuilder (remindlongwords); Style.setspan (New Foregroundcolorspan (Getresources () GetColor (r.color.deepblue_wor d)), start, end, spannable.span_exclusive_inclusive); Sets the color of the specified position text remindwords.settext (style); Remindwords.setonclicklistener (this); *//need to listen for the range of click Start end int start = Zw_longtext.length () + 3; int end = Zw_longtext.length () + 3 + zw_bluetext.length (); 1. You must create a new span spannablestring spstr = new spannablestring (remindlongwords); 2.NoLineClickSpan write the color and click event for the location Nolineclickspan Clickspan = new Nolineclickspan (wantupdkpresenter.factorydk MaiNmodel.zw_type, Getresources (). GetColor (R.color.deepblue_word)); 3.span Help Top click Span Spstr.setspan (Clickspan, start, end, spanned.span_inclusive_exclusive); 4. Need to set down str remindwords.settext (SPSTR); 5. Set TextView can click Remindwords.setmovementmethod (linkmovementmethod.getinstance ()); }
Nolineclickspan is a class that inherits from Clickspan and overrides the color and click events with the following code:
/** * Created by AA on 2015/4/24. * Nolineclickspan is a class that inherits from Clickspan, overriding the color and click events, the code is as follows: */public class Nolineclickspan extends Clickablespan { int type; int showcolor; Public Nolineclickspan (int type,int cl) { super (); This.type=type; SHOWCOLOR=CL; } @Override public void Updatedrawstate (Textpaint ds) { ds.setcolor (showcolor); Ds.setunderlinetext (FALSE); Remove underline } @Override public void OnClick (View widget) { //processhyperlinkclick (text);// Call log.e ("onclick", "already clicked") when clicking the hyperlink; Intent intent=new Intent (Widget.getcontext (), uniapplyactivity.class); Intent.putextra ("type", type); Widget.getcontext (). StartActivity (intent); }}
TextView Click the specified string to jump to TextView hyperlink effect