TextView implementation highlighting, underlined, with background, mainly through the Spannablestring class implementation.
For specific implementations, see the code:
1 TextView showmorecontent= (TextView) Findviewbyid (r.id.showmorecontent); 2 spannablestring span= Spannablestring (Showmorecontent.gettext (). toString ());
3 Span.setspan (new Foregroundcolorspan (color.red), 0//new Foregroundcolorspan () to set text highlighting 4 Span.setspan (new Underlinespan (), 0< Span style= "color: #000000;" >, Showmorecontent.gettext (). toString (). Length (), spannable.span_exclusive_exclusive);
//new Underlinespan () set text underline 5 showmorecontent.settext (span);
Sets the background color to be implemented by new Backgroundcolorspan (int).
TextView jump by setting the onclick
Please look at the code:
1Showmorecontent.setonclicklistener (NewOnclicklistener () {2 3 @Override4 Public voidOnClick (View v) {5 //TODO auto-generated Method Stub6Intent intent=NewIntent (mainactivity. This, Morecontent.class);7 startactivity (intent);8 }9});
Android development TextView for highlighting and clicking jump