yellavon
yellavon

Reputation: 2881

Store 2 dimentional array in strings xml

How do I store this 2 Dimensional array in strings.xml?

private String[][] children = {
        { "Arnold", "Barry", "Chuck", "David" },
        { "Ace", "Bandit", "Cha-Cha", "Deuce" },
        { "Fluffy", "Snuggles" },
        { "Goldy", "Bubbles" }
};

Upvotes: 0

Views: 1063

Answers (1)

LeffelMania
LeffelMania

Reputation: 12875

Your usage case would help answer the question, because depending on your situation, my suggestion would be to put the individual Strings in strings.xml and then use an int[][] inside your class pointing to the string resources:

private final int[][] children = {
    { R.string.arnold, R.string.barry, R.string.chuck, R.string.david },
    { R.string.ace, R.string.bandit /*etc*/ }
    // etc
    // ...
};

I know that doesn't directly answer your question as to how to do that in XML, but unless you provide a usage case that makes it clear that it's necessary to do that, there's no reason to do anything harder than what I've described.

Upvotes: 1

Related Questions