1

How can I convert this type of Arraylist to Two Dimensional Arraylist ?

ArrayList<ArrayList<String>> two = new ArrayList<ArrayList<String>>();

In android ExpandableListView does not allow to use Arraylist to populate the listview. But I have to dynamically populate the data from JSON web service. How Can I solve this issue ?

Any help would be great !

1
  • well your second dimension for array vary which is not suitable Commented Jun 21, 2012 at 7:32

2 Answers 2

1

If you're coming from a JSON object, then the data is already in the format that you want. It's already an array of arrays. You can just loop through the first array assigning the second as you go.

String[][] foo = new String [myJsonObject.getStringArray("arrayOfArrays")).length() ][];
for(int i = 0; myJsonObject.exists("array_" + i); i++){
   foo[i] = myJsonObject.getStringArray("array_" + i);
}

I didn't test this, so the syntax might not be 100% but you get the idea.

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

Comments

0

You just create a Hashmap first and put data to the hashmap. And then Create a Arraylist and put hashmap inside arraylist. That is i done in my case of multidimensional array.

Comments

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.