Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio (Kotlin) how to convert StringArray to MutableList

Tags:

android

kotlin

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!>!

like image 652
Simon Andersson Avatar asked Jun 11 '26 22:06

Simon Andersson


1 Answers

I solved it with

var morality = (activity.resources.getStringArray(R.string.morality).toMutableList())
like image 200
Simon Andersson Avatar answered Jun 13 '26 11:06

Simon Andersson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!