Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Problem is that when <code>Linify.addLinks()</code> is called first thing what this method does is removing all spans. When you use <code>Html.fromHtml()</code> <code>Spanned</code> is return, so when <code>Linkify</code> parse text again firstly remove "html links". I wrote a simply class <code>LinkifyExtra</code>. It has one extra method </p> <pre><code>public class LinkifyExtra extends Linkify { public static Spanned addLinksHtmlAware(String htmlString) { // gather links from html Spanned spann = Html.fromHtml(htmlString); URLSpan[] old = spann.getSpans(0, spann.length(), URLSpan.class); List&lt;Pair&lt;Integer, Integer&gt;&gt; htmlLinks = new ArrayList&lt;Pair&lt;Integer, Integer&gt;&gt;(); for (URLSpan span : old) { htmlLinks.add(new Pair&lt;Integer, Integer&gt;(spann.getSpanStart(span), spann.getSpanEnd(span))); } // linkify spanned, html link will be lost Linkify.addLinks((Spannable) spann, Linkify.ALL); // add html links back for (int i = 0; i &lt; old.length; i++) { ((Spannable) spann).setSpan(old[i], htmlLinks.get(i).first, htmlLinks.get(i).second, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } return spann; } } </code></pre> <p>and use it like that</p> <pre><code> String htmlstring = "http://google.com &lt;a href=\"http://google.com/\"&gt;Google!&lt;/a&gt;"; textView = (TextView)findViewById(R.id.textView1); textView.setText(LinkifyExtra.addLinksHtmlAware(htmlstring)); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setLinksClickable(true); </code></pre> <p>And it works. But you can't use <code>mTextViewBio.setAutoLinkMask(Linkify.ALL);</code>because it triggers <code>addLinks()</code> and remove "html links". Depends of what you want to do in bigger picture, this method may need some changes. I skip checking if spans are overlapping because I suppose it can't happen but if I am wrong you can simply copy <a href="http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.1.2_r1/android/text/util/Linkify.java#Linkify.pruneOverlaps%28java.util.ArrayList%29" rel="nofollow">this</a> method.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload