Display html values in Text view android - android

How can i display html values in textview in android.
Sample output response is in this link: http://pastebin.com/KYMTKAss .
Similarly i ve many classes and values. How can i fetch these html values into a string and display them in Textview. Please guide me.
Thanks.

Have you tried with Html.fromHtml already?

You can parse HTML using JSoup. The jar is about 132k, which is a bit big, but if you download the source and take out some of the methods you will not be using, then it is not as big. Have a look on HTML Parsers

Related

Android: Html.fromHtml() method not working with standard Html tags

So I have an HTML string I want to display as styled text in a textview but it never seems to work. My HTML string uses tags which are supposed to be supported by the fromHtml() method but it never displays the text properly, just returns the original HTML string. Here's an example of my HTML:
<div class="className"><p>Sample text http://www.example.com</p></div>
Nothing special as you can see, yet it never parses it correctly. Could it be that the method doesn't support the "class" attribute? If so, how do I add support for it?
Html class provides limited to support of HTML elements. And "class" attributes are not supported.
To understand which tags can be used and how they will be rendered refer to source code (android 5.0.1 r1). You can provide custom TagHandler or use WebView to display complex HTML page.
Give a try to this lib: https://github.com/SufficientlySecure/html-textview
It supports several tags more than native Html.fromHtml in Android.

MathJax with TextView in Android

I have some data which was formatted using MathJax on WebApplication. Now, I want to display those Data in Android App and that is in TextView only.I have already downloaded MathJax from Leathrum's WordPress
I found some examples but all are using WebView. But I want it using TextView. How to get this ???
I am also using ImageGetter with that TextView and it is working fine. Now, just want to do something for MathJax.
Why only TextView ???
My data contains simple text, html text, images, and math functions... I was using webview but it is showing extra space at bottom and also have using with Webview because I am using Custom ListView with WebView
But I want it using TextView. How to get this ?
You don't. TextView is not designed for this. Your choices are:
Stick with WebView
Figure out how to render your mathematical expressions to images, then either use an ImageView, ImageSpan, etc.
Write your own widget that draws the mathematical expression to a Canvas
MathJax is a cross-browser JavaScript library that displays mathematical notation in web browsers, using MathML, LaTeX and ASCIIMathML markup.
Source: MathJax in Wiki
The very first line has an answer for you. It's a cross-browser javascript library. you can not use it for textviews. Doesn't it make sense ?
Update:
Solution 1: You could write a mapper which will have mapping of each Math symbols to its html code and use it to showcase on your TextView based on need.
Solution 2: There is a nice open source: MathView Which is using MathJax internally that you can use.

display html content without using webviw in android

I wan to display html contents without using webview in android.
Contents are result of html parser.
But by now, I don't know how to do it. Is there any clue or example?
I think I need some example code to study it.
thank you very much.
You have to use Html.fromHtml()
Example :
myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>"));
Best Example here.

Html.fromHtml does not removes <!-- comments -->

I am currently parsing some HTML code and I would like to put in a Textview. (Webview is too much, I just want something very simple).
The Html.fromHtml(mySource) is great and working fine.
This line makes my text turn in colors, bold, italic, etc...
Unfortunately, it has some inconvenients, it does not remove the comments.
Do you have any solution other than using a WebView?
Remove the comments yourself before passing the string to Html.fromHtml(). Whether you use a regular expression or an HTML parser is up to you, though this gentleman has an opinion on the matter.

Formatting XML for display in a TextView?

Is there a tool/library/class/function for formatting XML when displaying it in a TextView in Android? I need to present some XML snippets to users and was looking for a convenient way to achieve this, rather than having to parse and format it manually...
Thanks
This post will help you
How to pretty print XML from Java?

Categories

Resources