简体   繁体   中英

showing http images from html using webview

i want to show the images from http not stored in local. am not able to show images.

    webView = (WebView) findViewById(R.id.webView1);
    webView.getSettings().setJavaScriptEnabled(true);


    String customHtml = "<html><body>"
            + "<h1>Hello, WebView</h1>"
            +"<img src="+"'http://dreamatico.com/data_images/flowers/flowers-5.jpg'"+" height="+142+" width="+142+">"
            + "</body></html>";
    webView.loadData(customHtml, "text/html", "UTF-8");

Create the html file and put it in the assets folder and load that html file using

 WebView mWebView = null;
    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.loadUrl("file:///android_asset/new.html");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM