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

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

Related

How to create PDF file with only one long page?

I have a very big HTML file. For now, i'm using HTML2PDF converter to make PDF from HTML, which works just fine for me, but it splited my html to a few pages. But what i want to achieve is the whole HTML content on one (long) single page. How can i do this (without $ libs) ?
Maybe i can foreach every single page in my pdf document and "merge" it in a one big page ?
Thanks in advance !

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.

HTML A Name attribute on android browser

I have a web page with about 150 HTML <a name="blah"></a> elements, plus 26 more that group these by letter, like <a name="lettera"></a>.
The page passes W3C HTML validation and renders and operates correctly in desktop browsers. Trying two different Android browsers and an emulator, the letter index does not work. When any letter is selected, the page only moves to the lettera tag. The location bar correctly shows <site>page.htm#letterx as the current location, but the display has not moved.
Other pages on the same site with a smaller number of name tags work correctly. I found one web reference saying that some browsers did not like to see two name tags in a row and suggesting placing the nonsense tag in between them to break them up, but this did not help. Any suggestions?
Answering my own question in case it helps someone else someday, it appears there needs to be actual renderable content between two successive name tags for the android browser (a comment alone didn't do it). When I added some all worked as intended.

What should I use for getting data out of HTML

I hope you can point me in a right direction,
Im making a Android app that gets content of a website,
At the moment my app loads dat webpage in a webview, but the page is to wide for almost every screen, so i had another idea:
webcontent(html) -> get contents of table with android -> make a listview -> when sliding right you get another day.
the webcontent is a timetable for school, a example is this one http://intranet.staring.nl/toepassingen/rooster/lochem/2W2/2012102920121104/2W01532.htm
what i want is that every day comes in a listview and that a user can swap right or left to change the day there seeing.
Now im getting already stuck on making the listview from the html source, can somebody help me with this?
You should access those data using a webservice...
Because otherwise you'll need to download a LOT of useless HTML code + parse it...
But IF this is the way you want to go, or you have no control over that website, you could read the file and simply parse it using regular expressions I guess.
Here are some tools I found:
JTidy
JSoup
Parsing HTML in Java?

Categories

Resources