String url="注册代表宝藏驱动器,你已经允许成员《服务条款》,请仔细阅读。"; SpannableStringBuilder style = new SpannableStringBuilder(url); TextViewURLSpan myURLSpan = new TextViewURLSpan(); style.setSpan(myURLSpan,12,20, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); tv_service.setText(style); tv_service.setMovementMethod(LinkMovementMethod.getInstance());
private class TextViewURLSpan extends ClickableSpan{ @Override public void updateDrawState(TextPaint ds) { ds.setColor(getResources().getColor(R.color.c_new_blue)); ds.setUnderlineText(false); //去掉下划线 } @Override public void onClick(View widget) {//点击事件 Intent intent=new Intent(getApplicationContext(),RegServiceA.class); startActivity(intent); } }
版权声明:本文博主原创文章,博客,未经同意不得转载。