Chad Adams
Chad Adams

Reputation: 1329

Android WebView pulling it multipe html pages that change based on user swipe

I'm trying to figure out how to set up a WebView that displays a defined array of local HTML pages using Android's WebView. I also want to be able to swipe between each page in the array using a flick left or right. Any thoughts on how to implement this?

The code below should give you an idea of what I'm going for:

private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    webview = (WebView) findViewById(R.id.webview);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.loadUrl("file:///Android_Assets/HTML/page1.html, file:///Android_Assets/HTML/page2.html, file:///Android_Assets/HTML/page3.html");

    view.loadUrl(url);
    return true;
}

}

Upvotes: 1

Views: 2227

Answers (1)

m0s
m0s

Reputation: 4280

WebView won't load multiple pages like that what you have in your code snippet. What you want to do is probably read your pages into strings and then use WebView.loadData to load into your webview. And here is detailed info how to implement swipe.

Upvotes: 1

Related Questions