2011-04-28 33 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文件 - 安卓]的
相关问题