Question

I have a main page (main.html) in the assets folder that I am displaying with:

webview.setWebChromeClient(new MyWebChromeClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.addJavascriptInterface(new VersionCallbackScript(), "demo");
webview.loadUrl("file:///android_asset/main.html");

and I want to put a link in the document to another html file in assets folder. When I similiarly put in the tag:

<a href="file:///android_asset/secondpage.html">Touch here for page 2</a></font></h4>

and touch it in the client, the screen loads a blank page.

likewise, I want to have a table of contents that isA ListView and uses loadUrl with an html page suffixed with an anchor. I tried and it is not working

String anchor = "subsection1";
webview.loadUrl("file:///android_asset/main.html" + "#" + anchor);

this construct is not working either.

Was it helpful?

Solution

Give a try to the following piece of code

<a href="secondpage.html">Touch here for page 2</a>

For me it does the job.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top