开发者

Retrieving the JSON data into a list view

I successfully opened Httpclient connection. Now I want to select data from JSON and show it in a list. I 开发者_如何学Gogoogled it from half day but can't find any help. A sample project or code snippet would be really helpful.


In the past I've used gson to parse JSON. The org.json package provided in the SDK seems a little low-level.

Now I want to select data from JSON and show it in a list.

When you say "select data" do you mean use queries to retrieve subsets of your data? jxpath looks like an interesting solution. If you're just displaying the entire JSON data then you should be able to simply wrap gson's output in an adapter.

I googled it from half day but can't find any help.

  • DuckDuckGo: json android
  • DuckDuckGo: json android listview
  • Stack Overflow: json android listview

The last one would have led you to this question, of which yours is an exact duplicate.

A sample project or code snippet would be really helpful.

Examples abound! From the above search links:

  • gson parsing
  • gson parsing and displaying in a ListView


You'll have to use http://developer.android.com/reference/org/json/JSONTokener.html or something similar to decode your JSON data.

After doing that you need to update your list model on your list view.

I'm under the impression that for your application http://developer.android.com/reference/android/widget/ArrayAdapter.html might suit your needs.

If you already have an array adapter, you probably just need to update that adapter.

I don't have specifics on that though. Hopefully this will put you on the right track.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜