
public class TextViewLinkActivity extends Activity {
TextView myTextView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myTextView = (TextView) this.findViewById(R.id.myTextView);
SpannableString sp = new SpannableString("这句话中有百度超链接,有高亮显示,这样,或者这样,还有斜体.");
sp.setSpan(new URLSpan("http://www.baidu.com"), 5, 7,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sp.setSpan(new BackgroundColorSpan(Color.RED), 17 ,19,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
sp.setSpan(new ForegroundColorSpan(Color.YELLOW),20,24,Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
sp.setSpan(new StyleSpan(android.graphics.Typeface.BOLD_ITALIC), 27, 29, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
myTextView.setText(sp);
myTextView.setMovementMethod(LinkMovementMethod.getInstance());
}