@Android display /res/viewable in WebView

Posted by MikeNereson on Stack Overflow See other posts from Stack Overflow or by MikeNereson
Published on 2010-04-13T15:25:20Z Indexed on 2010/04/13 15:53 UTC
Read the original article Hit count: 402

Filed under:
|
|

I am throwing HTML to a webview to render. In the HTML I need to load an image that I have in /res/drawable.

I have /res/drawable/my_image.png and code such as this:

final WebView browser = (WebView) findViewById(R.id.my_webview);
String html = new MyHelper(myObject).getHtml();
browser.loadDataWithBaseURL("", html, "text/html", "UTF-8", "");

Where the String html has something like:

<html><head>
<h1>Here is the image</h1>
<img src="my_image.png" />
</head><html>

The question is, what should that image src attribute be to refer to the image in /res/drawable

~Thanks

© Stack Overflow or respective owner

Related posts about android

Related posts about webview