2

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!

1 Answer 1

6

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.