14

This time I want to get an array-list element from strings.xml and convert it to an array (String[], List or whatever can later be used to read the elements or the total size). I am trying with List<String> MathFormulas = Arrays.asList(getResources().getStringArray(R.id.StringArray)); but the application crashes, so this must be the wrong way of doing it. Some help? Thanks!

2
  • 04-23 17:10:30.101: E/AndroidRuntime(1516): Caused by: android.content.res.Resources$NotFoundException: String array resource ID #0x7f08000f Commented Apr 23, 2012 at 17:39
  • 2
    Please add an update to your question instead of posting it as a comment. Commented Apr 23, 2012 at 17:40

3 Answers 3

25

you can convert it to string arrar as below::

String[] cmd = getResources().getStringArray(R.array.StringArray);

or

List<String> MathFormulas = Arrays.asList(getResources().getStringArray(R.array.StringArray));
Sign up to request clarification or add additional context in comments.

Comments

11

I see that you are using identifier R.id.StringArray when it should start with R.array. The rest of the code looks OK to me.

1 Comment

It was that. I am staying in front of this stupid plastic box since this morning. I am loosing my minds. Thanks!
1

Try R.array.StringArray instead of R.id.StringArray.

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.