Define string array

suggest change

In order to define a string array write in a resources file

res/values/filename.xml

<string-array name="string_array_name">
    <item>text_string</item>
    <item>@string/string_id</item>
</string-array>

for example

res/values/arrays.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="string_array_example">
        <item>@string/app_name</item>
        <item>@string/hello_world</item>
    </string-array>
</resources>

and use it from java like

String[] strings = getResources().getStringArray(R.array.string_array_example;
Log.i("TAG",Arrays.toString(strings)));

Output

I/TAG: [HelloWorld, Hello World!]

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents