URLSpan用于設(shè)置點擊鏈接事件,點擊相應(yīng)文字可以跳轉(zhuǎn)到特定鏈接。
需要配置?mTxHintView.movementMethod = LinkMovementMethod.getInstance()
參考代碼如下:
var spannerString = SpannableString("登陸即代表您已閱讀并同意用戶協(xié)議及隱私政策")
val xieyiURLSpan = URLSpan("http://www.reibang.com/p/")
val yinsiURLSpan = URLSpan("http://www.reibang.com/p/")
spannerString.setSpan(xieyiURLSpan, 12, 16, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
spannerString.setSpan(yinsiURLSpan, 17, 21, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
mTxHintView.text = spannerString
mTxHintView.movementMethod = LinkMovementMethod.getInstance()