关键代码:
mConTv?.setMovementMethod(LinkMovementMethod.getInstance())
spannableStringBuilder=SpannableStringBuilder()
spannableStringBuilder?.append("请您认真阅读")
val serviceSp= SpannableString("《用户协议》")
serviceSp.setSpan(object :ClickableSpan() {
override fun onClick(widget: View) {
IntentUtils.goServiceProvision(mContext)
}
override fun updateDrawState(ds: TextPaint) {
super.updateDrawState(ds)
ds.setUnderlineText(false)
}
}, 0, serviceSp.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
serviceSp.setSpan(ForegroundColorSpan(Color.parseColor("#4c9ee8")), 0,
serviceSp.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
spannableStringBuilder?.append(serviceSp)
spannableStringBuilder?.append("和")
val privacySp= SpannableString("《隐私政策》")
privacySp.setSpan(object :ClickableSpan() {
override fun onClick(widget: View) {
IntentUtils.goPrivacy_policy(mContext)
}
override fun updateDrawState(ds: TextPaint) {
super.updateDrawState(ds)
ds.setUnderlineText(false)
}
}, 0, privacySp.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
privacySp.setSpan(ForegroundColorSpan(Color.parseColor("#4c9ee8")), 0,
privacySp.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
spannableStringBuilder?.append(privacySp)
spannableStringBuilder?.append("的全部条款,接受后可开始使用我们的服务。")
mConTv?.setText(spannableStringBuilder)