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?
You need to set the link in the text, and use the autoLink
attribute for it. It will use the marked text as link. Otherwise, the only option is to use an OnClickListener
as suggested by nicholas.
You can look at the autoLink
attribute doc here: http://developer.android.com/reference/android/widget/TextView.html#attr_android:autoLink
If 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.