【发布时间】:2015-08-27 15:19:18
【问题描述】:
我想更改链接(文本视图)的默认颜色。
SpannableString ss = new SpannableString("By continuing,I agree to HCP User Agreement and Terms of Services ");
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View textView) {
startActivity(new Intent(UserRegister.this, ForgotPassword.class));
}
};
ss.setSpan(clickableSpan, 48, 65, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
TextView textView = (TextView) findViewById(R.id.termsAndConditions);
textView.setText(ss);
textView.setMovementMethod(LinkMovementMethod.getInstance());
【问题讨论】:
-
ss.setSpan(new ForegroundColorSpan(Color.RED),48,65,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) -
我有他们使用 wordtoSpan.setSpan(new ForegroundColorSpan(Color.BLUE), 15, 30, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);但是我应该在哪里传递 clickablespan 对象
-
@Raghunandan 那么我应该在哪里传递 ClickableSpan 的对象