Skip to content

Instantly share code, notes, and snippets.

@Dminter
Created July 10, 2015 03:19
public class URLSpanUtil extends URLSpan {
public URLSpanUtil(String url) {
super(url);
}
@Override
public void updateDrawState(TextPaint ds) {
ds.setColor(UtilApplication.ctx.getResources().getColor(R.color.underline_color));
ds.setUnderlineText(false);
}
@Override
public void onClick(View widget) {
// super.onClick(widget);
Context context = widget.getContext();
String url = getURL();
if (StrUtil.notEmptyOrNull(url)) {
//这里简单判定url
if (url.startsWith("http") || url.startsWith("https")) {
//跳转到自己的webview处理
Intent intent = new Intent(context, WebViewActivity.class);
context.startActivity(intent);
}else {
super.onClick(widget);
}
}else {
super.onClick(widget);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment