将JSON数组显示到ListView android中

时间:2014-03-14 09:36:29

标签: android json listview

我从某个网址获取JSON响应。此响应包含一些文本和图像URL。

我想创建一个ListView,我可以在其中显示缩略图图片,标题和一些描述。

我该怎么做?

我的JSON: -

  [
 {
        "SourceId": "ea9c86e1-c638-45dd-9619-8d7053458a48",
        "ArticleGuid": "5bd475e8-945f-444b-93d5-7a1a0d757557",
        "Url": "https://zsome/DispForm.aspx?ID=1",
        "Title": "something",
        "Body": "<div><p>​<img alt=\"_MG_2375-58.jpg\" src=\"some/_MG_2375-58.jpg\" style=\"margin&#58;5px;width&#58;266px;vertical-align&#58;auto;float&#58;left;\" /></p><font size=\"3\"><p> blah blah",
        "EnterpriseKeywords": "",
        "ThumbnailPath": "https://some.net/5bd475e8-945f-444b-93d5-7a1a0d757557/_MG_2375-58.jpg",
        "ThumbnailDescription": "",
        "ImageUrls": "someurl/-58.jpg",
        "ImageBlobUrls": "some/475e8-945f-444b-93d5-7a1a0d757557/_MG_2375-58.jpg",
        "isPlaceHolderForThumbnail": false,
        "PublishedDate": "2014-03-02T15:39:00Z",
        "NumberOfComments": 9,
        "NumberOfViews": 13,
        "CreatedDate": "2014-03-03T00:43:08Z",
        "AuthorEncodedAccountName": "acnanjak",
        "AuthorDisplayName": "abc",
        "ID": 1,
        "SourceTitle": "New",
        "SourceUrl": "https://xome.com"
    },
    {
        "SourceId": "ea9c86e1-c638-45dd-9619-8d7053458a48",
        "ArticleGuid": "5bd475e8-945f-444b-93d5-7a1a0d757557",
        "Url": "https://zsome/DispForm.aspx?ID=1",
        "Title": "something",
        "Body": "<div><p>​<img alt=\"_MG_2375-58.jpg\" src=\"some/_MG_2375-58.jpg\" style=\"margin&#58;5px;width&#58;266px;vertical-align&#58;auto;float&#58;left;\" /></p><font size=\"3\"><p> blah blah",
        "EnterpriseKeywords": "",
        "ThumbnailPath": "https://some.net/5bd475e8-945f-444b-93d5-7a1a0d757557/_MG_2375-58.jpg",
        "ThumbnailDescription": "",
        "ImageUrls": "someurl/-58.jpg",
        "ImageBlobUrls": "some/475e8-945f-444b-93d5-7a1a0d757557/_MG_2375-58.jpg",
        "isPlaceHolderForThumbnail": false,
        "PublishedDate": "2014-03-02T15:39:00Z",
        "NumberOfComments": 9,
        "NumberOfViews": 13,
        "CreatedDate": "2014-03-03T00:43:08Z",
        "AuthorEncodedAccountName": "acnanjak",
        "AuthorDisplayName": "abc",
        "ID": 1,
        "SourceTitle": "New",
        "SourceUrl": "https://xome.com"
    }]

1 个答案:

答案 0 :(得分:0)

可以使用自定义库从路径加载图像。 您可以使用Picaso加载图片,也可以参考此Tutorial

如果你收到错误就试试吧,你可以发布logcat以获得更多帮助。

谢谢。