text 文本样式粗斜体以及在listView中使用超链接

// Get our EditText object.
EditText vw = (EditText)findViewById(R.id.text);

// Set the EditText's text.
vw
.setText("Italic, highlighted, bold.");

// If this were just a TextView, we could do:
// vw.setText("Italic, highlighted, bold.", TextView.BufferType.SPANNABLE);
// to force it to use Spannable storage so styles can be attached.
// Or we could specify that in the XML.

// Get the EditText's internal text storage
Spannable str = vw.getText();

// Create our span sections, and assign a format to each.
str
.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, 7, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
str
.setSpan(new BackgroundColorSpan(0xFFFFFF00), 8, 19, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
str
.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 21, str.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

http://developer.android.com/intl/zh-CN/guide/appendix/faq/commontasks.html

或者

mBox = new TextView(context); mBox.setText(Html.fromHtml("<b>" + title + "</b>" +  "<br />" +                         "<small>" + description + "</small>" + "<br />" +                         "<small>" + DateAdded + "</small>");

 

想在listView中使用超链接 可以继承custom adapter并在getView

textcontent.setText(Html.fromHtml(item.get_text()));
textcontent
.setAutoLinkMask(Linkify.WEB_URLS);
然后在

<TextView
               
android:id="@+id/txtview"
               
android:autoLink="web"
               
android:layout_width="fill_parent"
               
android:layout_height="fill_parent"
               
android:text="put your link here"/>

 下标:

mtTextView.setText(Html.fromHtml("HC0<sub>3</sub>"));

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值