Display an image in the webview

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Display an image in the webview

Postby prachi_584 » Tue Nov 11, 2008 7:39 am

Hi,

I have an HTML doc called test.html which I have kept in the raw folder. I want to display this doc in webview. Here's my code:

try {
InputStream is = getResources().openRawResource(R.raw.test);
int size = is.available() ;
byte[] buffer = new byte[size];
is.read(buffer);

data = new String(buffer);
is.close();

}
catch (Exception e) {
Log.e("", "ResourceUtils failed to load resource to string", e);
}

view.loadData(data, "text/html", "UTF-8");


The html doc also contains an image tag. Here's my html code:


<html>
<body>

<form name="input" action="html_form_action.asp" method="get">
Male:
<input type="radio" name="Sex" value="Male" checked="checked">
<br>
Female:
<input type="radio" name="Sex" value="Female">
<br>
<input type ="submit" value ="Submit">
</form>

<p>
If you click the "Submit" button, you will send your input to a new page.
</p>

<p>
An image:
<img src="icon.png"
width="144" height="50">
</p>

</body>
</html>


I want to display icon.png image. But it is unable to display the image.
I have kept this image in the same folder as that of html doc.
What is wrong with my code?
Need help!!!!

Thanx.
User avatar
prachi_584
Freshman
Freshman
 
Posts: 6
Joined: Tue Nov 04, 2008 6:28 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests