首页 > 解决方案 > 如何在 Kotlin 中放置和获取要捆绑的字符串列表

问题描述

假设有字符串列表,如

val list = listOf("a", "b")

如何将它保存到 Kotlin 的 Bundle 中并从中获取?

我试过这样保存,但它给出了类型不匹配错误

outState.putStringArrayList(KEY, list.toTypedArray())

Type inference failed. Expected type mismatch
Required: ArrayList<String!>?
Found: Array<String>

标签: kotlinarraylistandroid-bundleandroid-savedstate

解决方案


推荐阅读