3

I want to get a StringArray from Resources and convert it into a MutableList

I tried the following code

var morality = mutableListOf(activity.resources.getStringArray(R.string.morality))

but it gives me an error saying

Type mismatch Required: String? Found: ArrayOut<(out)String!>!

1
  • it says found: MutableList<Array<(out)String!>!> Commented Jun 22, 2017 at 17:35

1 Answer 1

9

I solved it with

var morality = (activity.resources.getStringArray(R.string.morality).toMutableList())
Sign up to request clarification or add additional context in comments.

2 Comments

You could also use mutableListOf(*activity.resources.getStringArray(R.string.morality)) (notice the *)
How to get String array like resources.getStringArray(R.array.category) ?

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.