2
我想加载一个图像并从网址WebView
中从网址中提取一些其他细节,方法是将其插入到html代码 中,但是当我尝试加载一个图像,它在WebView
中只显示一个问号。我无法在webview中使用带有图像url的html代码加载图像
这里是代码
String htmlDetails(String extract) {
String desc, link;
String cost, model, ratings, specifications;
Document document = Jsoup.parse(extract);
extract = document.text();
Elements description = document.select("a");
Elements img = document.select("img[src]");
Elements modelvalue = document.select("h2[class=a-size-base a-color-null s-inline s-access-title a-text-normal]");
model = modelvalue.text().toString();
Elements costvalue = document.select("div[class=a-row a-spacing-mini]");
cost = costvalue.text().toString();
Elements ratingvalue = document.select("div[class=a-row a-spacing-none]");
ratings = ratingvalue.text().toString();
Elements specificationvalue = document.select("ul[class=a-row a-spacing-top-mini a-spacing-mini]");
specifications = specificationvalue.text().toString();
desc = description.html();//attr("content");*/
desc = img.attr("src").toString();
desc = desc.substring(2);
link = "http://10.0.2.2/andro/"+desc;
String Html = "<html>"
+"<body>"
+"<img src='"+link+"' width='30px' height='50px'/>"
+"</body>"
+"</html>";
return Html;
}
webview.lodaData(htmlDetails(HTML_String), "text/html", "UTF-8");
搜索并阅读关于WebViewClient和shouldOverrideUrlLoading方法。 – Manish