我已经在SD卡的根下载了map750.png文件,但是当我试图用一些文本在webview中显示它时,只显示文本。你能帮我找出代码中的错误吗?谢谢。显示来自SD卡的图像与webview不工作
setContentView(R.layout.webview);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setBuiltInZoomControls(true);
String html = "<html><head></head><body><p>hello</p><img src=\"file://mnt/sdcard/map750.png\" alt=\"alternativo\" /></body></html>";
mWebView.loadData(html, "text/html","utf-8");
我编辑帖子以添加oneilse14建议的解决方案,谢谢!
setContentView(R.layout.webview);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setBuiltInZoomControls(true);
String html = "<html><head></head><body><p>hello</p><img src=\"file://mnt/sdcard/map750.png\" alt=\"alternativo\" /></body></html>";
mWebView.loadDataWithBaseURL("", html, "text/html", "utf-8", "");
检查我的答案肯定会工作。 –
如何从SD卡加载SVG图像? –