For the webview to find the image, you need to place it into the directory /assets/ (you probably need to create this directory).
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, "");
}
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, "");
}
No comments:
Post a Comment