How-to use a WebView with custom HTML from a string, which references a local image. For the webview to find the image, you need to place it into the directory /assets/ (you probably need to create this directory).
/**
* This code loads a custom HTML from a string which references a local image
* - for this to work, simply place the image in the directory /assets/
*/
public void loadHTML() {
final String mimeType = "text/html";
final String encoding = "utf-8";
final String html = "<h1>Header</h1><p>Custom HTML</p><p><img src=\\"file:///android_asset/image1.jpg\\" /></p>";
WebView wv = (WebView) findViewById(R.id.wv1);
wv.loadDataWithBaseURL("fake://not/needed", html, mimeType, encoding, "");
}
1 Comment
Hello! Base klooper in place of my english jer, buti very nice re say gJ$)Kd!!!.