Display HTML document in Activity - android

I am parsing an RSS feed using SAX to display a list of the title of the latest posts.
When I click the title, it opens the browser, showing that URL.
However I want to display the article, including the HTML styling and images in a new activity.
I can get the article part by parsing the variable 'encoded'
Link.
It is pure HTML. It also contains <img src='...'> tags.
What would be the best way to display this in an activity?
TextView can display HTML, but I don't think it displays images.
Webview can show local HTML, but in this case, it will be dynamic.
Is there any way to display an HTML document in an Activity, including styling and images?

I think you need a webview. There's more info here too.

Related

diplaying mathematical equtaions in android app

I am creating a mathematics app and have to display mathematical equations in my app. There are many answers related to this but I am not able to conclude how to do this?
As mentioned in the comments above you can use that library MathView or other possibilities are ,
You can go with using the spannable string and can make superscripts
and subscripts easily.
You can also use the HTML.fromHTML(String html) which will give you
the spanned text and that you can set it to the TextView.
Or else show a webview and load the html page that contains the
formulas and solutions. (This will be like creating a dynamic html
files with in the app and showing it in the Webiew)

Open list of relative urls absolutely in android TextView?

In my application (target 4.0), I have a chunk of HTML (which was pulled and parsed from a webpage) that I am displaying in a TextView. This HTML contains a large number of links (up to 100), most of which are relative, but some are absolute. I want the user to be able to click these relative urls URLs to launch a web browser.
How can I do this without going through the HTML and changing the URLs? Can I tap into a link click event?
You have to set a WebViewClient to your WebView and override shouldOverrideUrlLoading (and perhaps onLoadResource too).
You can match URL (and other patterns) using Linkifyand you can parse your content to use <a> tags like this:
Android Make hyperlinks in textview clickable
In other words, you need the href to contain a fully qualified URL, but you can still display the relative URL to the user.
No client URL works without full qualification, so you need to give the client a context. But this allows you to display relative URL's to the user.

Android parsing XML data example, webView or listView?

I'm following this tutorial and I modified the example code to let it work for my XML file, now it renders HTML into a webView and the result is a raw list of items (not very beautiful). I don't understand why it chose a webView to display data. Now I don't know how to go forward, should I follow the original approach adding CSS styles and HTML or should I get data and display them with a native listView? my problem is that the whole example is build on the HTML string composition and it seems quite difficult to modify to get only data and put in a listview.

Show html image and table in textview

I am using a simple textview to show some html string in my android app. If I show only text with links I have no problem, but when I receive some data which contains images and tables the images are showing like obj string only and the tablet are not even shown, only the text part is showing. I know I can use webview, but i don't have so much control of the contents view and I can't customize it so much as in textview.
Is there any way that I can show tables and images in textview, while the images are saved on sd card. I don't need any methods to download them from internet and stuff like that.
Any help / suggestions / advices are appreciated!
No. TextView is not WebView. Use the latter for more markup that elementary attributes like <B>, <U> or tags like <A>

Take an element from a website and put into an android app

Okay noob of the year question.
I have a website, which has several div. and one of those div I would like to put as the front end of an android app.
I.E, I have this div id
I want to put that entire element as the android application. Of course add buttons for it for various items, but right now that is my main obsticle.
I dont want to hard code the page into the android application, becuase of course that element changes.
Thank you in advance.
You could use a WebView to display a Website inside your application. See this article. If you want to display only one div of a website, you could move this div to another page. This should be the easiest method to achieve your goal.
BTW: There are no stupid questions ;-)
One option would be to code your site so that this DIV has a unique ID assigned to it. You could then download all of the HTML from your site into a string in your app, parse out this individual div you want (by finding the unique ID) and save it in a string named, say, html. Next you can place this DIV inside of a webview using webView.loadData(html, mimeType, encoding); where "html" is a string containing the div you extracted. So long as that DIV has content that has absolute paths to resources (images/links), it should load and display your content properly

Categories

Resources