package com.about;
import android.text.TextPaint;
import android.text.style.URLSpan;
public class URLSpanNoUnderline extends URLSpan {
public URLSpanNoUnderline(String url) {
super(url);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
}
}
上面的代码是URLSpanNoUnderline.java代码,调用它然后在需要去除下划线的activity的textview中加上如下例子的代码。
tvll_1_3_weiboaddress = (TextView) findViewById(R.id.about_ll_1_3_weiboaddress);
SpannableString text = new SpannableString("weibo.com/smartits");
text.setSpan(new URLSpanNoUnderline("http://weibo.com/smartits"), 0,
18, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
tvll_1_3_weiboaddress.setText(text);
tvll_1_3_weiboaddress.setMovementMethod(LinkMovementMethod.getInstance());