【发布时间】:2012-04-29 15:13:17
【问题描述】:
我的 /res/raw/test.html 中有一个 HTML 文件
我使用以下代码在 web 视图中显示它
WebView wbview = (WebView)findViewById(R.id.webView1);
InputStream fin;
try
{
fin = getResources().openRawResource(R.raw.manual);
byte[] buffer = new byte[fin.available()];
fin.read(buffer);
fin.close();
wbview.loadData(new String(buffer), "text/html", "UTF-8");
}
catch (IOException e)
{
e.printStackTrace();
}
这是我的 HTML 文件的代码
<html>
<p>
Lorem ipsum dolor sit amet,
</p>
<table>
<tr>
<td>
<img src=\\"file:///android_asset/test_image2.jpg\"/>
<img src="test_image2.jpg" width="50px" alt="Hi">
<img src=\"res/drawable/test_image.png"/>
<img src="file:///android_res/drawable/test_image.png" />
<img src=\"file:///android_res/drawable/test_image.png"\ />
</td>
</tr>
</table>
</html>
我想在我的 html 文件中显示我的资源文件夹中的图像... 我尝试了所有的可能性仍然不起作用。它只是显示 HTML 文本,但对于图像我不知道如何显示它
请帮帮我
【问题讨论】:
-
您可以通过 Jonas Alves stackoverflow.com/questions/4534043/…查看这个答案
标签: android