2011-04-28 62 views
0

我可以加載本地sdcard圖像文件到android中的web視圖。如果是這樣如何? 我想在Web視圖中顯示來自SD卡的圖像文件。我該怎麼做它我可以加載本地sdcard文件到web視圖中android

+0

可能重複(http://stackoverflow.com/questions/5812277/open-local -html文件功能於網頁瀏覽式的機器人) – Nanne 2011-04-28 06:01:54

回答

0

可以使用獲得SD卡路徑 -

"file:///" + Environment.getExternalStorageDirectory().getAbsolutePath() + "/"; 

然後用Webview 's loadData

加載圖像

0
Here images is the name of the folder containing images 

字符串的ImagePath = this.getFilesDir( ).getAbsolutePath()+「/ images /」;

 if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) 
    { 
     Log.d("", "No SDCARD"); 
    } else { 
     webView.loadUrl("file://"+imagePath+imageName); 

}

0

試試這個:

String htmlContent = "<html><body><p><img src=\"file:///sdcard/image_name.jpg\" width=\"200\" height=\"133\" alt=\"\" /></p></body></html>"; 
webView.loadDataWithBaseURL("not_needed", htmlContent, "text/html", "utf-8", "not_needed"); 
[在網頁視圖打開本地的HTML文件 - 安卓]的