//显示富文本
String html="<font color='red'>样式一</font> <br>"; html+="<font color='#0000FF'> <big> <i> 样式二 </i> </big> <font>"; html+="<font color='@"+android.R.color.white+"'> <tt> <b> <big> <u> 样式三 </u> </big> </b> </tt> </font> <br>"; html+="<big> <a href='http://blog.csdn.net/a_mean'>我的博客:http://home.cnblogs.com/u/lrfsmile/ </a> </big>"; CharSequence charsequence=Html.fromHtml(html); tv.setText(charsequence);
//显示图片
Bitmap bitmap=BitmapFactory.decodeResource(getResources(), R.drawable.test);
ImageSpan imagespan=new ImageSpan(this, bitmap);
SpannableString spannableString=new SpannableString("icon");
spannableString.setSpan(imagespan, 0, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.setText(ss);
//点击文字跳转到自定义界面
String str="点击显示自定义Activity";
SpannableString spannableString=new SpannableString(str);
spannableString.setSpan(new ClickableSpan() {
@Override
//单击时要执行的动作
public void onClick(View widget) {
// TODO Auto-generated method stub
Intent intent=new Intent(MainActivity.this, Activity1.class);
startActivity(intent);
}
}, 0, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.setText(spannableString);
//再单击链接时凡是要执行的动作都必须设置MovementMethod对象
tv.setMovementMethod(LinkMovementMethod.getInstance());