Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the count of array from resources file?

I have multiple arrays in resources like this:

<resources>
<string-array name="myArray1"> 
    <item>String1</item> 
    <item>String2</item> 
    <item>String3</item> 
</string-array> 

<string-array name="myArray2"> 
    <item>String1</item> 
    <item>String2</item> 
    <item>String3</item> 
</string-array> 

<string-array name="myArray3"> 
    <item>String1</item> 
    <item>String2</item> 
    <item>String3</item> 
</string-array> 
</resources>

Now how to get the count of these array dynamically?currently I have 3 arrays.

I can get the particular array items like this

String[] resourceString =getResources().getStringArray(R.array.myArray);

But how to get the count?

like image 271
Goofy Avatar asked Sep 16 '25 00:09

Goofy


1 Answers

int length =getResources().getStringArray(R.array.myArray).length;
like image 146
user1969053 Avatar answered Sep 17 '25 13:09

user1969053