如何构建列表并从JSON中提取数据?

时间:2015-05-20 05:48:19

标签: android json

我正在Android Studio中开发Android设备,我正在做一个需要构建列表的应用程序,并通过标准HTML调用从JSON中将数据传递给它。

有人可以为列表提供代码示例吗,或者甚至是一个示例项目,其中列表显示您下载的JSON数据?

我在谈论JSON:

http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo

{
  "geonames": [
    {
      "lng": -99.12766456604,
      "geonameId": 3530597,
      "countrycode": "MX",
      "name": "Mexiko-Stadt",
      "fclName": "city, village,...",
      "toponymName": "Mexico City",
      "fcodeName": "capital of a political entity",
      "wikipedia": "en.wikipedia.org/wiki/Mexico_City",
      "lat": 19.428472427036,
      "fcl": "P",
      "population": 12294193,
      "fcode": "PPLC"
    },
    {
      "lng": 116.397228240967,
      "geonameId": 1816670,
      "countrycode": "CN",
      "name": "Peking",
      "fclName": "city, village,...",
      "toponymName": "Beijing",
      "fcodeName": "capital of a political entity",
      "wikipedia": "en.wikipedia.org/wiki/Beijing",
      "lat": 39.9074977414405,
      "fcl": "P",
      "population": 11716620,
      "fcode": "PPLC"
    }
  ]
}

1 个答案:

答案 0 :(得分:0)

首先制作一个简单的列表视图,然后解析列表适配器中的json。

请查看示例android-json-parsing-tutorial

希望这会对你有所帮助