0

嗨,我制作了一个程序来加载文件夹中的图像。(路径是 sdcard/scheduler/pic.jpg)。我要加载这张图片并显示它。我的图片应该可以放大。所以我使用网络视图来显示图像。代码如下

mWebView = (WebView) findViewById(R.id.webview);

         mWebView.getSettings().setAllowFileAccess(true);
         mWebView.getSettings().setJavaScriptEnabled(true);
         mWebView.getSettings().setBuiltInZoomControls(true);

  String imagePath = "file:/sdcard/Schedular/233322.jpg";
          String html = "<html><head></head><body><img src=\""+ imagePath + "\"></body></html>";
          mWebView.loadData(html, "text/html","utf-8");

此代码不加载图像的问题。它只给出白屏。我认为这是路径的问题。请给个解决办法。。

4

1 回答 1

0

您提供了错误的图像路径。Environment.getExternalStorageDirectory()会给你SD卡路径。从这个起点开始,您应该构建图像的路径。

于 2012-04-18T15:16:00.013 回答