I have a large set of html-pages (css-formatted, + some javascript) that I want saved inside the project so the user dont have to go online to browse for them from the app.
1) My first question is how do I open a a local html-page (named, for instance "myWebPage.html") in a WebView?
I know I can make a WebView load a html-string with the following code:
main.xml
WebKitTest.java
But I dont know how to load a specific local html-page.
2) My second question is: where do I put the html-pages? I understand that resources are generally put in the /res/-folder of the project, but do I put them in a specific sub-folder of the res-folder?
1) My first question is how do I open a a local html-page (named, for instance "myWebPage.html") in a WebView?
I know I can make a WebView load a html-string with the following code:
main.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView android:id="@+id/webkit"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
WebKitTest.java
Code:
package com.androidspanishcourse.WebKitTest;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class WebKitTest extends Activity {
// Declare webview
WebView browser;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// ?
browser=(WebView)findViewById(R.id.webkit);
// Loads html-string into webview
browser.loadData("<html><body>Hi dude<br><br>Hi again</body></html>", "text/html", "UTF-8");
}
}
But I dont know how to load a specific local html-page.
2) My second question is: where do I put the html-pages? I understand that resources are generally put in the /res/-folder of the project, but do I put them in a specific sub-folder of the res-folder?