thunderousNinja
thunderousNinja

Reputation: 3520

Is it possible to populate a spinner in android using a JSONArray?

Just as the title says.. Is it possible to do this? Say I have a JSON array of something like this

{
    "locations": [
      {
        "id": 1,
        "loc": "miami"
      },
      {
        "id": 2,
        "loc": "manhattan"
      },
      {
        "id": 3,
        "loc": "lasVegas"
      }
    ]
  }

Upvotes: 0

Views: 515

Answers (2)

ChandlerSong
ChandlerSong

Reputation: 487

you can convert the json to a java object. and bind the data.

Upvotes: 0

dmon
dmon

Reputation: 30168

Sure, extend BaseAdapter and use the JSONArray as your backing model. However, it would be better (but by no means necessary) to convert it to a more "natural" representation in Java and use that instead.

Upvotes: 1

Related Questions