TextView Useinfo = (TextView) Findviewbyid (R.ID. info); Useinfo.settext ("At the beginning, you agree to abide by"); String url_0_text ="User Agreement and Privacy policy"; Spannablestring spstr =Newspannablestring (url_0_text); Spstr.setspan (NewClickablespan () {@Override Public voidupdatedrawstate (textpaint ds) {super.updatedrawstate (DS); Ds.setcolor (Color.White); //Set File ColorDs.setunderlinetext (true);//Set Underline} @Override Public voidOnClick (View widget) {log.d ("","Ontextclick ....."); } }, 0, Url_0_text.length (), spanned.span_exclusive_exclusive); Useinfo.sethighlightcolor (color.transparent); //set the color after the click is transparent, otherwise it will always appear highlighteduseinfo.append (spstr); Useinfo.setmovementmethod (Linkmovementmethod.getinstance ());//start Responding to click events
TextView underline, partial text and respond to click events (spannablestring)