2

Are there any rules around (or just the regexp) that explain which URL's a Html.fromHtml(...) call will linkify / accept when placed in an < a > tag?

I ask as I'm wasting hours trying to work out what causes some links to be clickable, while others are unclickable (rendered as plain text) by the call e.g

If you stick ALL of the following in a:

TextView aboutText = (TextView) v.findViewById(R.id.about_text);
        aboutText.setText(Html.fromHtml(.....

call it accepts / will render as a link:

<p> ... the <a href="http://developer.android.com/samples/index.html">Developer.android.com samples</a>, </p>  

<p> - https://en.wikipedia.org/wiki/Android_(operating_system)</p>

But it won't accept the Wikipedia link presented as:

    <p> - <a href="https://en.wikipedia.org/wiki/Android_(operating_system)">Wikipedia: 
Android</a></p>

The textview has the android:autoLink="web" attribute set.

arober11
  • 1,969
  • 18
  • 31
  • 1
    Use Linkify like http://stackoverflow.com/questions/4746293/android-linkify-textview OR use setMovementMethod() like http://stackoverflow.com/questions/9852184/android-textview-hyperlink/11498305 ? – Stan Apr 09 '15 at 10:26
  • Has no effect, try putting all 3 links in the same string / block and make the call. I can't get the last one to be clickable whatever I do, the first two are fine, with or without a: ***Linkify.addLinks(...., Linkify.WEB_URLS);*** or ***.setMovementMethod(LinkMovementMethod.getInstance());*** call. – arober11 Apr 09 '15 at 10:33
  • Anyway, per the question I'm after the rules, as annoying that some links render while others don't, and I can't work out the reason why. – arober11 Apr 09 '15 at 10:39
  • http://stackoverflow.com/questions/4303160/how-can-i-make-links-in-fromhtml-clickable-android – Jemshit Mar 07 '16 at 12:14

0 Answers0