pRaNaY pRaNaY - 19 days ago 6
Android Question

Android webview cant load html text

I am trying below code for webview, but i cannot get o/p in webview with given data input.

Below input text i want to view in webview.

String aboutUsString="
<p><img alt="" src="//c2.staticflickr.com/6/5783/20923557613_322bef1d7a_k.jpg" /></p>
<p><img alt="" src="//c2.staticflickr.com/6/5702/20923558493_cd3ff898b7_k.jpg" /></p>
<p><img alt="" src="//c1.staticflickr.com/1/688/21356640050_39abf858ba_k.jpg" /></p>
";


Webview code:-

public void setWebpage() {
if (!aboutUsString.equals("")) {
webview.getSettings().setJavaScriptEnabled(true);
webview.loadDataWithBaseURL("", aboutUsString, "text/html", "utf-8", "");
}
}

Answer

Try by adding the protocol(http:) to the URL you are giving to the 'p' tag. Replace the <p><img alt="" src="//c2.staticflickr.com/6/5783/20923557613_322bef1d7a_k.jpg" /></p> with

<p><img alt='' src='http://c2.staticflickr.com/6/5783/20923557613_322bef1d7a_k.jpg' /></p>

Hope this helps!

Comments