Android Question Detect Text on Clicked Area

Discussion in 'Android Questions' started by Marcos Alves, Feb 17, 2019.

  1. Marcos Alves

    Marcos Alves Active 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...
     

    Attached Files:

  2. DonManfred

    DonManfred Expert 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.
     
    Last edited: Feb 18, 2019
    Erel likes this.
  3. Marcos Alves

    Marcos Alves Active Member Licensed User

    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 ?
     
  4. DonManfred

    DonManfred Expert Licensed User

    I don´t know.
    I only know the Charsequencebuilder
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice