1


i got this JSONArray but i cant figure out how to put it in a listview. i figured out the ArrayAdapter but is doesnt give me the right result

[{"id":"1","name":"Joris","sex":"1","birthyear":"1987"},{"id":"2","name":"bjorn","sex":"1","birthyear":"1987"},{"id":"3","name":"Mel","sex":"0","birthyear":"1992"},{"id":"4","name":"Peter","sex":"1","birthyear":"1955"},{"id":"5","name":"Geer","sex":"1","birthyear":"1979"}]

this is my result on the phone in a list after using ArrayAdapter.
Can somebody help me?

{"id":"1","name":"Joris","sex":"1","birthyear":"1987"}
{"id":"2","name":"bjorn","sex":"1","birthyear":"1987"}
{"id":"3","name":"Mel","sex":"0","birthyear":"1992"}
{"id":"4","name":"Peter","sex":"1","birthyear":"1955"}
{"id":"5","name":"Geer","sex":"1","birthyear":"1979"}
3
  • what do you want to put in list view, i mean name, sex, birthyear etc????? Commented Nov 17, 2010 at 15:22
  • 1
    Based on the title of the question, do you think yo have a multi-dimensional array? You do not. You have an array of objects. Commented Nov 17, 2010 at 15:22
  • ok that is one thing i needed to know thats its not a multi array. but i only want the values after ":"-sign (dont know english word). So the real values. This is what came out of a mysql-db from my website. Commented Nov 18, 2010 at 0:19

2 Answers 2

1

This json parsing in java example can help

Sign up to request clarification or add additional context in comments.

Comments

0

I don't know how you moved round it, but if would have done it this way.

The string you have is a collection of JSON objects, it's JSON array in terms of Java, so first step would be to parse that array and get each row in an ArrayList. This ArrayList shall be ArrayList of String[], where each row shall be an array containing id, sex, birthyear etc.

You can check this post for parsing JSON: JSON Parsing in Android

Next step would be to create a custom listAdapter so that I can pass my created ArrayList and fetch elements from it and display in whatever way I want.

1 Comment

yep i know the last step. but thanx for the url.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.