String url = data.blockChainUrl; //https or http url
SpannableStringBuilder builder = new SpannableStringBuilder("");
int start = builder.length();
String content = mContext.getResources().getString(R.string.block_chain_query); //填充字體顏色
builder.append(content);
int end = builder.length();
builder.setSpan(new URLSpanNoUnderline(url) {
@Override
public void onClick(View widget) {
super.onClick(widget);
}
}, start, end, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
builder.setSpan(new ForegroundColorSpan(ContextCompat.getColor(mContext, R.color.color_a5ef44)), 0,
end, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
mBlockChainQuery.setText(builder);
//必須有的set mBlockChainQuery.setMovementMethod(LinkMovementMethod.getInstance());
//自定義一個URLSpan
為象州等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及象州網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為網(wǎng)站制作、做網(wǎng)站、象州網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
class URLSpanNoUnderline extends URLSpan {
public URLSpanNoUnderline(String url) {
super(url);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
//you self
}
}