Skip to content
Advertisement

Android Resource – Array of Arrays

I am trying to implement a resource data structure that includes an array of arrays, specifically strings. The issue I run into is how to get the sub-array objects and their specific values. Here is what my resource file looks like….

JavaScript

Then, in my Java code I retrieve the array and try to access the sub elements like so…

JavaScript

At this point the typedArray object should represent the string-array “array01”, however, I don’t see how to retrieve the “id” and “title” string elements. Any help would be appreciated, thanks in advance.

Advertisement

Answer

You can almost do what you want. You have to declare each array separately and then an array of references. Something like this:

JavaScript

Then in your code you do something like this:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement