2013-08-31 67 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