1
WebView wv = (WebView) findViewById(R.id.webview1);
    wv.setWebViewClient(new Callback());
    WebSettings webSettings = wv.getSettings();
    webSettings.setBuiltInZoomControls(true);

    final String mimeType = "text/html";
    final String encoding = "UTF-8";
    String html = "<H1>A simple HTML page</H1><body>" +"<a>link using anchor tag</a>"+

            "<p>The quick brown fox jumps over the lazy dog</p>";
            wv.loadDataWithBaseURL("", html, mimeType, encoding, "");

リンク後、画像を表示したいので。/imagesそれで、それがsdcardのフォルダに保存されている場合、その画像のアドレスをどのように置くか、つまりsrc属性のアドレスは何である必要がありますか?

よろしく

4

2 に答える 2

0
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setBuiltInZoomControls(true);
String base = Environment.getExternalStorageDirectory().getAbsolutePath().toString();
String imagePath = "file://"+ base + "/test.jpg";
String html = "<html><head></head><body><img src=\""+ imagePath + "\"></body></html>";
mWebView.loadDataWithBaseURL("", html, "text/html","utf-8", "");  
于 2012-12-21T14:43:42.090 に答える
0

imagePathで、画像の場所を設定します。ここのように、その表示されているtest.jpgファイルはimagesフォルダーに保存されます。

 String base = Environment.getExternalStorageDirectory().getAbsolutePath().toString();
 String imagePath = "file://"+ base + "/images/test.jpg";
 String html = "<html><head></head><body><img src=\""+ imagePath + "\"></body></html>";
  mWebView.loadDataWithBaseURL("", html, "text/html","utf-8", "");
于 2012-12-21T14:47:03.183 に答える