Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

string-array inside string-array

I want to create a string-array inside another string-array like this:

<string-array name="names">
        <string-array name="man">
            <item>Jake</item>
          </string-array>
            <string-array name="woman">
            <item>Loise</item>
          </string-array>
</string-array>

But I don't know how to access to de string-array inside the main string-array. Before doing it this way, I had organized all names in the same string-array and I accessed this way:

String names[] = res.getStringArray(R.array.names);

But now I need to classify the data. How can I access to the SUB string-arrays?

Thank you in advance!

like image 525
anonymous Avatar asked May 18 '12 10:05

anonymous


People also ask

Can you put an array inside an array?

Nested Array in JavaScript is defined as Array (Outer array) within another array (inner array). An Array can have one or more inner Arrays. These nested array (inner arrays) are under the scope of outer array means we can access these inner array elements based on outer array object name.

How do you get an array inside an array?

Creating a Nested Array This one is just equating the variable to the array. Second one is using the array method new Array() . And the last one is using the Array() which is similar to the new Array() .

Is string [] the same as array string?

There's no difference between the two, it's the same.

How do you join an array of strings into a single string in Java?

Create an empty String Buffer object. Traverse through the elements of the String array using loop. In the loop, append each element of the array to the StringBuffer object using the append() method. Finally convert the StringBuffer object to string using the toString() method.


1 Answers

The outer array should be an array, not a string array (since it's not holding strings anymore). You want to declare the string arrays separately, and then an array with references to these string arrays as described here (SO-thread, see accepted answer). Retrieval is also explained.

like image 101
keyser Avatar answered Sep 25 '22 06:09

keyser