I have this layout:
<TextView
android:clickable="true"
android:focusable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView" />
And this code to implement and set my customized URLSpan as the textView text
val urlSpan=object:URLSpan("http://10.0.2.2/feed.xml") {
override fun onClick(widget: View?) {
longToast("link was clicked!")
}
}
val spannableString=SpannableString("this is a spannable link")
spannableString.setSpan(urlSpan, 10, 19, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
textView.text = spannableString
But the onClick event of my customized URLSpan never triggers :( I've searched and nothing seems to work.
I've read this: android custom URLSpan not working and other threads but it was in vain.