This is seems like a pretty simple question, but I’m not sure if there’s a solution to it. Is it possible to set a custom action for a text link (those blue texts that are underlined) inside a TextView? In other words, is it possible to have a handler do something on an event like onClick on the link?
Share
You need to set the link in the text, and use the
autoLinkattribute for it. It will use the marked text as link. Otherwise, the only option is to use anOnClickListeneras suggested by nicholas.You can look at the
autoLinkattribute doc here: http://developer.android.com/reference/android/widget/TextView.html#attr_android:autoLinkIf your text is: “You will find it at http://www.example.com“, and you set
android:autoLink="web", then the link will be highlighted and a browser will start after clicking it.