0

I'm trying to show display an HTML string that I get as content from the server.

1)

<img alt="Https%3a%2f%2fblueprint-api-production.s3.amazonaws.com%2fuploads%2fcard%2fimage%2f131488%2fap_16181711733011" src="http://i.amz.mshcdn.com/yTdMVoJcGanbLCen51NCXh2HHgc=/575x323/https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com%2Fuploads%2Fcard%2Fimage%2F131488%2FAP_16181711733011.jpg">
<div>
  <a href="http://twitter.com/share?via=Mashable&text=The+Academy+just+took+a+huge+step+toward+ending+%23OscarsSoWhite&url=http%3A%2F%2Fmashable.com%2F2016%2F06%2F29%2Facademy-incoming-class-oscars-so-white%2F%3Futm_campaign%3DMash-Prod-RSS-Feedburner-All-Partial%26utm_cid%3DMash-Prod-RSS-Feedburner-All-Partial">
    <img alt="Feed-tw" src="http://a.amz.mshcdn.com/assets/feed-tw-f7c0a094d16b7ee7c91a1e50839a8e00.jpg" border="0">
  </a>
  <a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fmashable.com%2F2016%2F06%2F29%2Facademy-incoming-class-oscars-so-white%2F%3Futm_campaign%3DMash-Prod-RSS-Feedburner-All-Partial%26utm_cid%3DMash-Prod-RSS-Feedburner-All-Partial&src=sp">
    <img alt="Feed-fb" src="http://a.amz.mshcdn.com/assets/feed-fb-c0a21e8841794479b8086c32c6f24ba1.jpg" border="0">
  </a>
</div>
<div>
  <p>LOS ANGELES — For all the grief the Academy of Motion Picture Arts and Sciences has taken for <span>#OscarsSoWhite — much of it deserved, some incidental to the industry it represents — you can't say they haven't made an effort to make this right. Not after Wednesday, anyway.</span>
  </p>
  <p><span>AMPAS just announced <a href="http://www.app.oscars.org/class2016/?hq_e=el&hq_m=467892&hq_l=1&hq_v=92c4c068ef">its incoming class for 2016</a>: 683 active actors, directors, writers and other Hollywood operators. And get this: 41% of those are people of color.</span>
  </p>
  <div>
    <p>SEE ALSO: <a data-crackerjax="#post-slider" href="http://mashable.com/2016/06/19/hollywood-asian-americans/?utm_campaign=Mash-Prod-RSS-Feedburner-All-Partial&utm_cid=Mash-Prod-RSS-Feedburner-All-Partial">Hollywood is finally opening up to Asian Americans</a>
    </p>
  </div>
  <p><span>That new infusion moves the needle from 8% people of color in the Academy overall (an abysmal number) to 11% (a somewhat less abysmal number). But that's how you turn an aircraft carrier — one hard-fought degree at a time.</span>  <a href="http://mashable.com/2016/06/29/academy-incoming-class-oscars-so-white/?utm_campaign=Mash-Prod-RSS-Feedburner-All-Partial&utm_cid=Mash-Prod-RSS-Feedburner-All-Partial">Read more...</a>
  </p>
</div>More about <a href="http://mashable.com/category/oscars/?utm_campaign=Mash-Prod-RSS-Feedburner-All-Partial&utm_cid=Mash-Prod-RSS-Feedburner-All-Partial">Oscars</a>, <a href="http://mashable.com/category/awards/?utm_campaign=Mash-Prod-RSS-Feedburner-All-Partial&utm_cid=Mash-Prod-RSS-Feedburner-All-Partial">Awards</a>,
<a
href="http://mashable.com/category/oscarssowhite/?utm_campaign=Mash-Prod-RSS-Feedburner-All-Partial&utm_cid=Mash-Prod-RSS-Feedburner-All-Partial">Oscarssowhite</a>, <a href="http://mashable.com/category/the-academy-awards/?utm_campaign=Mash-Prod-RSS-Feedburner-All-Partial&utm_cid=Mash-Prod-RSS-Feedburner-All-Partial">The Academy Awards</a>, and <a href="http://mashable.com/category/movies/?utm_campaign=Mash-Prod-RSS-Feedburner-All-Partial&utm_cid=Mash-Prod-RSS-Feedburner-All-Partial">Movies</a>
  <img
  height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/Mashable/~4/CCdsReJZ4AI">

2)

<table cellpadding="2" border="0" cellspacing="7">
  <tr>
    <td width="80" align="center" valign="top"><font><a href="http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNHMsFZzwgIWn_QVXz1i4ja_vzCAWg&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779144035033&ei=-it0V6DLG9OEhQGy5JOwDA&url=https://www.nhl.com/news/oilers-trade-taylor-hall-to-devils-for-adam-larsson/c-281082608"><img height="80" alt="" width="80" src="http://t2.gstatic.com/images?q=tbn:ANd9GcQjZ0_-OrtEy4EYRH9yuujd-xVA-SSV2vPMNVrk1Vu38s074mpStUsGmKpMlodG1uEN8Fdy0_g" border="1"><br><font size="-2">NHL.com</font>
      </a>
      </font>
    </td>
    <td valign="top"><font><br><div><img height="1" alt="" width="1"></div><div><a href="http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNHMsFZzwgIWn_QVXz1i4ja_vzCAWg&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779144035033&ei=-it0V6DLG9OEhQGy5JOwDA&url=https://www.nhl.com/news/oilers-trade-taylor-hall-to-devils-for-adam-larsson/c-281082608"><b>Oilers trade Hall to Devils for Larsson</b></a><br><font size="-1"><b><font color="#6f6f6f">NHL.com</font>
      </b>
      </font>
      <br><font size="-1">The Edmonton Oilers traded left wing Taylor Hall to the New Jersey Devils for defenseman Adam Larsson on Wednesday. Hall, 24, had 65 points (26 goals, 39 assists) in 82 games this season. Taken by the Oilers with the first pick of the 2010 NHL Draft <b>...</b></font>
      <br><font size="-1"><a href="http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNHU8SI0YuY45TFYS5bM4lPDrgwjIA&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779144035033&ei=-it0V6DLG9OEhQGy5JOwDA&url=http://www.sbnation.com/nhl/2016/6/29/12061076/edmonton-oilers-trade-taylor-hall-to-devils-for-defenseman-adam-larsson">Edmonton Oilers trade Taylor Hall to Devils for defenseman Adam Larsson</a><font color="#6f6f6f" size="-1"><span>SB Nation</span></font></font>
      <br><font size="-1"><a href="http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNGKLDn9L7d4te1L2k3xcRGvzmTizQ&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779144035033&ei=-it0V6DLG9OEhQGy5JOwDA&url=http://www.foxsports.com/nhl/story/devils-acquire-former-no-1-pick-tyler-hall-from-oilers-062916">Devils acquire former No. 1 pick Tyler Hall from Oilers (Jun 29, 2016)</a><font color="#6f6f6f" size="-1"><span>FOXSports.com</span></font></font>
      <br><font size="-1"><a href="http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNG5pZAY6YTksB1rBuBI3pDbnv2Kvg&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779144035033&ei=-it0V6DLG9OEhQGy5JOwDA&url=http://nesn.com/2016/06/nhl-trade-rumors-oilers-deal-taylor-hall-to-devils-for-adam-larsson/">NHL Trade Rumors: Oilers Deal Taylor Hall To Devils For Adam Larsson</a><font color="#6f6f6f" size="-1"><span>NESN.com</span></font></font>
      <br><font size="-1"><a href="http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNFEFnTT_HOQsw3Blv_2p_-V1jnEZg&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779144035033&ei=-it0V6DLG9OEhQGy5JOwDA&url=http://www.sportingnews.com/nhl/news/taylor-hall-trade-nj-devils-oilers-adam-larsson-nhl-free-agency-rumors/26cy0kuycevx1t2vnd50opg97"><span>Sporting News</span></a> -<a href="http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNGApMEvfFT-RJ8XNmEkd_yvzSXIXg&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779144035033&ei=-it0V6DLG9OEhQGy5JOwDA&url=http://www.cbssports.com/nhl/news/oilers-send-taylor-hall-to-devils-in-stunning-trade/"><span>CBS sports.com (blog)</span></a></font>
      <br><font size="-1"><a href="http://news.google.com/news/more?ncl=dphuwoc95lSJMYMiW383gX0akIahM&authuser=0&ned=us&topic=h"><span><b>all 28 news articles »</b></span></a></font>
      </div>
      </font>
    </td>
  </tr>
</table>

The method Html.fromHtml() has been deprecated, also it does not handle iframe tags.

Dylan Wheeler
  • 6,928
  • 14
  • 56
  • 80

2 Answers2

0

try below answer.. hope this solves your problem. Let me know if you still face any issues

https://stackoverflow.com/a/37905107/2779404

Community
  • 1
  • 1
Prashant
  • 188
  • 4
  • I tried that, but it does not handle the embedded video tags. – Prateek Tank Jul 18 '16 at 18:42
  • You can try another way round to handle your requirement. Pattern p = Pattern.compile(" – Prashant Jul 18 '16 at 18:52
  • That is a nice workaround, but is there no way to sort of embed them in the textview in between the text lines? – Prateek Tank Jul 18 '16 at 19:06
  • I think, it is not possible to handle – Prashant Jul 18 '16 at 19:15
  • Is it possible to insert a dynamic videoview in between the spanned text in a textview?. I have seen many apps( not the code ) that don't use a WebView but have a embedded video for example - Palabre. So there must be a way? – Prateek Tank Jul 19 '16 at 03:17
0

You have to use

Html.fromHtml(String, int) //for 24 api and more

and

Html.fromHtml(String, int) //for old apis
Akshay Panchal
  • 695
  • 5
  • 15