如何从 json 字符串中获取图像 url android 要在图像中显示view

发布时间: 2016/9/16 13:19:06
注意事项: 本文中文内容可能为机器翻译,如要查看英文原文请点击上面连接.

伙计们这是我的 json 数据︰

{
  "status": "ok",
  "post": {
    "id": 8,
    "type": "post",
    "slug": "android",
    "url": "http://192.168.1.8/Android/android/wordpress/2016/07/13/android/",
    "status": "publish",
    "title": "Android",
    "title_plain": "Android",
    "content": "<p>Google&#8217;s Android is shaking up the mobile market in a big way. With Android.</p>\n<p><img class=\"alignnone size-medium wp-image-31\" src=\"http://192.168.1.8/Android/android/wordpress/wp-content/uploads/2016/07/51KRggHZuzL._SX355_-300x222.jpg\" alt=\"51KRggHZuzL._SX355_\" width=\"300\" height=\"222\" srcset=\"http://192.168.1.8/Android/android/wordpress/wp-content/uploads/2016/07/51KRggHZuzL._SX355_-300x222.jpg 300w, http://192.168.1.8/Android/android/wordpress/wp-content/uploads/2016/07/51KRggHZuzL._SX355_.jpg 355w\" sizes=\"(max-width: 300px) 85vw, 300px\" /> <img class=\"alignnone size-medium wp-image-12\" src=\"http://192.168.1.8/Android/android/wordpress/wp-content/uploads/2016/07/CV2iAeMXIAAQlZH-300x232.png\" alt=\"moto\" width=\"300\" height=\"232\" srcset=\"http://192.168.1.8/Android/android/wordpress/wp-content/uploads/2016/07/CV2iAeMXIAAQlZH-300x232.png 300w, http://192.168.1.8/Android/android/wordpress/wp-content/uploads/2016/07/CV2iAeMXIAAQlZH.png 600w\" sizes=\"(max-width: 300px) 85vw, 300px\" /></p>\n",
    "excerpt": "<p>Google&#8217;s Android is shaking up the mobile market in a big way. With Android.  </p>\n",
    "date": "2016-07-13 06:12:00",
    "modified": "2016-07-18 07:12:39"
  }
}

内容数据中我这样得到的字符串︰

<p>Google&#8217;s Android is shaking up the mobile market in a big way. With Android.</p>\n<p><img class=\"alignnone size-medium wp-image-31\" src=\"http://192.168.1.8/Android/android/wordpress/wp-content/uploads/2016/07/51KRggHZuzL._SX355_-300x222.jpg\" alt=\"51KRggHZuzL._SX355_\" width=\"300\" height=\"222\" srcset=\"http://192.168.1.8/Android/android/wordpress/wp-content/uploads/2016/07/51KRggHZuzL._SX355_-300x222.jpg 300w, http://192.168.1.8/Android/android/wordpress/wp-content/uploads/2016/07/51KRggHZuzL._SX355_.jpg 355w\" sizes=\"(max-width: 300px) 85vw, 300px\" /> <img class=\"alignnone size-medium wp-image-12\" src=\"http://192.168.1.8/Android/android/wordpress/wp-content/uploads/2016/07/CV2iAeMXIAAQlZH-300x232.png\" alt=\"moto\" width=\"300\" height=\"232\" srcset=\"http://192.168.1.8/Android/android/wordpress/wp-content/uploads/2016/07/CV2iAeMXIAAQlZH-300x232.png 300w, http://192.168.1.8/Android/android/wordpress/wp-content/uploads/2016/07/CV2iAeMXIAAQlZH.png 600w\" sizes=\"(max-width: 300px) 85vw, 300px\" /></p>\n

所以,如何我得到图像从该字符串的 url

解决方法 1:

Try this::

Document doc = Jsoup.parse(html);
        Elements element = doc.getAllElements();
        for(Element e: element)
        {
            Elements str = e.getElementsByTag("img");
            for(Element el: str)
            {                
                String src= el.attr("src");
                System.out.println("The src:"+src);
            }
        }
赞助商