Reputation: 358
Trying to display the Github Gists from a String in a TextView. When I clean the String from the HTML with 'Html.fromHtml()' -->
<p>Lorem ipsum dolor sit <a href="http://Lorem ipsum.com/Lorem ipsum dolor sit amet">amet</a>,</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam ultrices lorem scelerisque year’s Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam ultrices lorem scelerisque<br />
</p>
<p>Interdum et malesuada fames ac ante ipsum primis in faucibus</p>
<p><script src="https://gist.github.com/LoremIpsum/d3c4dff75f555a54aa0f.js"></script>Donec ac ultrices elit. Curabitur elementum pulvinar augue a congue. Phasellus in quam ligula.<script src="https://gist.github.com/dolorSitAmet/53ae35ddd74bb0837c12.js"></script></p>
How can I show the Gists like in the picture below:
Upvotes: 2
Views: 212
Reputation: 13019
As the official documentation tells us, the Html.fromHtml()
method
Returns displayable styled text from the provided HTML string
Unfortunately, the reference is a bit vague about which HMTL tags are supported. I searched around a bit, and the source code at grepcode.com shows that the <script>
tag is not evaluated.
So the answer to your question is: with a TextView
, you can't. Use a WebView
instead. Click this link for a short introduction.
Upvotes: 1
Reputation: 6312
textView.setText(Html.fromHtml(htmlCode));
It will do your job.
Upvotes: 0