SpannableStringBuilder textSpanned4 = new SpannableStringBuilder("请按照 示例图片 上传兑奖凭证图片");
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View view) {
startActivity(new Intent(ConfirmRedeemActivity.this, BrowserPicActivity.class)
.putExtra("index", 0)
.putStringArrayListExtra("pathList", new ArrayList<String>() {
{
add(url);
}
}));
overridePendingTransition(R.anim.activity_in, 0);
}
public void updateDrawState(TextPaint ds) {
/**set textColor**/
ds.setColor(0xFF4E8DFF);
/**Remove the underline**/
ds.setUnderlineText(false);
}
};
textSpanned4.setSpan(clickableSpan,
4, 8, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
// textSpanned4.setSpan(new ForegroundColorSpan(0xFF4E8DFF),4,8,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
//注意:此时必须加这一句,不然点击事件不会生效
tvExample.setMovementMethod(LinkMovementMethod.getInstance());
tvExample.setText(textSpanned4);
重写ClickableSpan 的 updateDrawState方法 取消下划线 ,设置字体颜色。