I originally started out displaying a web page in the assets folder using a WebView. However I seem to have grown beyond that as my page is not behaving as I would expect. According to the developer docs WebView should only be used for static pages that have no interactions. CSS, javascript etc. are not enabled. This makes sense with the behavior I am seeing. While my page renders nicely in the dev environment browser it looks like plain HTML on the device with no css or javascript capabilities. So if I want to display a local (assets folder) html page with css and javascript etc. enabled how would I go about doing that? I assume tutorials exist for such a simple thing but my Googling is coming up empty.
On the off chance my links as bad here is the header.
<head>
<link href="folderA/folderB/file.css" rel="stylesheet" />
<script src="folderA/js/file.js"></script>
</head>
Thank You again for helping this noob.
JB
Just found this. Might be on the right track?
http://developer.android.com/guide/webapps/index.html
Citation, please. I have never seen such a claim, and there are many, many applications that use
WebViewwith “interactions”.CSS is most certainly enabled — in fact, AFAIK, there is no way to disable it even if you wanted to. JavaScript is disabled by default, but a simple call to
getSettings().setJavaScriptEnabled(true)on yourWebViewwill enable it.loadUrl("file:///android_asset/index.html")works, to load anindex.htmlfile in the root of your project’sassets/directory.For example, in this sample project, I load
file:///android_asset/book/0.htm(and other HTML files) intoWebViewwidgets loaded into aViewPager. Each HTML refers to a pair of CSS stylesheets using:In this sample project, I load some HTML out of assets and use some in-page JavaScript.
Now, I have not done much with directory structures inside of
assets/and trying to access things across directories. It is conceivable that you are running into some problem related to that.