How to select a word on a tap in TextView
/EditText
in android. I have some text in a TextView
/EditText
and when user taps on a word, I want that word to be selected and after that when I call getSelectedText() like method, it should return me the selected word.
Any Help would be appreciated.
My goal is to perform some action when user taps on a particular word in TextView
/EditText
.
Use Linkify, Use your own Regular Expression to invoke your routine on the click of a word.
See here for the WikiWord Example and Relevant Blogpost
UPDATE: Another better approach is to use
BreakIterator
:OLD ANSWER
I wanted to handle click in my own Activity. I solved it by following code: