2013-08-31 61 views
1

我使用WebView来显示从db文件加载的动态内容。在一个数据库表中我有HTML的代码。 WebView文件无法从保存的URL加载图像内容。android webview动态内容图像支持

样品HTML代码:

 <!doctype html> 
<meta charset='utf-8'> 
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'> 
<link rel='stylesheet' href='css/gumby.css'> 
<link rel='stylesheet' href='css/style.css'> 
<script src='js/libs/modernizr-2.6.2.min.js'></script> 
<div class='row'> 
    <div class='container'> 
     <div class='twelve columns centered ticket' style='background-color: #ffffff;'><p 
       style='text-align: right;direction: rtl;padding: 13px'> 
      blah balh blah</p> <img src='img/p20.jpg'></div> 
    </div> 
</div> 

然后我加载从分贝此内容:

answerView.loadData(c.getString(c.getColumnIndex("content")), "text/html; charset=UTF-8", null);` 

c是Cursor类型之前definded;

答案查看无法显示p24.jpg。

SRY我的英文不好..

回答

0

当然,这不能因为相对于你的WebView工作没有目录/文件img/p20.jpg

Please see this answer how to display offline images poperly in webview.

+0

我有IMG文件夹旁边调用的代码在哪里,我也尝试过使用资产和文件:/// android_asset中的img refrence但不工作呢! 和另一个问题是我不能使用loadDataWithBaseURL()mehthod因为它与我的数据库表结构冲突。 – Diako