-2

我在 JSON 中获取包含图像的 HTML 标记。当我在 WebView 中加载时不显示任何图像,为什么?

我想在显示图像和 TextView 的 WebView 中显示 HTML,但我的代码只显示文本但不显示图像。

知道为什么吗?

WebView      wv = (WebView) findViewById(R.id.webview1);


   String   htmldescription = school2.getJSONObject(0).getString("description");

wv.loadData(htmldescription, "text/html", "utf8");

              {"Status":1,
          "data":
 [
  {"product_id":"8569",


 "image":"data\/osc\/0\/10011-Scalp-Med-Hsdf.jpg",
  "manufacturer_id":"0",

 "name":"Scalp Med Hair Grow PC-0004..",

  "description":"<p><b><font face="Arial">Scalp Med Hair Grow PC-0004.. <\/font><\/b><\/p>    
  \r\n\r  
 \n<p><img border="0" height="257"
  src="http:\/\/www.megamall.com.pk\/image\/cache\/data\/10011-Scalp-Med-Hairfall-Solution- 
 800x800.jpg" width="261" \/><\/p>\r\n\r\n<p><b><font face="Arial" size="2">
 Features: <\/font><\/b><\/p>\r\n\r\n<p><font face="Arial" size="2"><b>Scalp Med Hair 
  Grow<\/b>    is an all natural formulation which includes the pure extracts of plants from 
 3 different continents.<br \/>\r\n<br \/>\r\nIs your Bald Spot getting bigger and bigger 
 every   month?<br \/>\r\nIs the hair on your shower floor getting thicker while it gets
thinner and thinner on your head?<br \/>\r\n<br \/>\r\nThen Scalp Med Hair Grow
 is for you. Scalp Med Hair Grow is an all natural formulation which includes the
 pure extracts of plants from 3 different continents. This tried and tested formulation
 will reach deep down to cleanse, revitalize and unblock the hair follicles allowing vital   
nutrients to reach the hair roots and allow hair to grow again.<br \/>\r\n<br \/>\r\nScalp
 Med Hair Grow is the only ecological product of its kind capable of treating alopecia 
 efficiently. In the first month, continual use of Scalp Med Hair Grow will recover
 and strengthen the hair follicles. In the second month, your hair will stop 
 falling out altogether. And by the third month, new hair will start to grow.
 <\/font><\/p>\r\n",
 "meta_description":"Scalp Med Hair Grow PC-0004.. Rs. 1199.0000\/- Buy Scalp 
  Med Hair Grow PC-0004.. Lifestyle > Fragrances & Beauty in Pakistan","meta_keyword":
 "Tablet PC, Laptops, Mobile Phones, Watches, China Mobiles, Refurbished Mobiles, 
  Head Phones, Nokia Lumia, Nokia Asha, Samsung Galaxy, Computers, Home Appliances, 
  Printer, Scanners, ipods, ipads, blackberry, htc, iphone, apple, nokia, sony, camera,    
 samsun","product_h1":"",

 }

]}
4

2 回答 2

2

要加载图像,您需要使用loadDataWithBaseURL. 要使用视图数据加载图像,请参阅链接。

于 2013-10-29T08:17:57.790 回答
0

得到你的 JSON 字符串后:

String content = HttpApi.getContent(URL);

您将传递以前的 URL 以在 webview 中加载数据

webview.loadDataWithBaseURL(URL, contentAfterParsing, "text/html", "UTF-8", null);

之后,您将在 webview 中看到图像

于 2013-12-19T07:24:20.617 回答