Using strings.xml items on a listview array

android, android-arrayadapter, android-listview, java

Solution

Create a string array resource in your strings.xml.

<string-array name="colors">
    <item>Red</item>
    <item>Green</item>
    <item>Blue</item>
</string-array>

Use your string array from your Java just like you would any other string resource.

private String[] colors = getResources().getStringArray(R.array.colors);

Problem

I'm coding an Android app with android studio. I'm displaying a ListView who gets its content from a String Array. I want to use the strings.xml items in the array of the listview, but I can't. Please help me. I'm doing this for the first item of the array: ``` public final String palanca= (getResources().getString(R.string.palanca)); private String [] formls = {palanca,"@string/uMR","@string/new1","@string/new2","@string/new3"}; ``` Thank You!

Original source