I know this is so easy (doh...) but I am looking for a way to run a method on tapping or clicking a TextView line of text in an Android App.
I keep thinking about button listeners and anonymous method listener calls, but it just does not seem to apply to TextView.
Can someone point me at some code snippet to show how clicking or tapping on a piece of text in a TextView runs a method?
To click on a piece of the text (not the whole
TextView
), you can useHtml
orLinkify
(both create links that open urls, though, not a callback in the app).Linkify
Use a string resource like:
Then in a textview:
Html
Using
Html.fromHtml
:Then in your textview:
in textView
You must also implement View.OnClickListener and in On Click method can use intent
I tested this solution works fine.