Android Question Detect Text on Clicked Area

Marcos Alves

Well-Known Member
Licensed User
I noticed that many apps have a feature that, when the user clicks over an email or web address, the text is automatically detected and the respective action is started.
Suppose that I have a text in a label on screen as follows, with an email and maybe a web address. Is there any easy way to detect the user touch and get an event with the text (considering that the spaces are the "elements dividers", I mean, is the user touches the email, I'll have the email address in the event data)?
This could be similar to WhatsApp or Line when an user touches a link or email...
 

Attachments

Marcos Alves

Well-Known Member
Licensed User
The webbrowser know all kind of links and create a "a" Tag for it.
In a Label you need to build this by yourself.

Use Charsequencebuilder and setup a Clickable part.
Hello @DonManfred ,

I don't think that Charsequencebuilder is a good solution because I already have a spannable text, copied from an email or a browser, and the links are already there. If I use Charsequencebuilder could need to create a flat text from HTML version of spannable and parse the HTML version, inserting the links with the library .
Isn't there a way to detect the word under the touch and generate an event , once I already have the spannable text in a object showed on screen ?
 
Top