admin管理员组文章数量:1304167
I have a generic rememberMutableStateListOf used across my app that keeps lists if screen configuration changes, like rotation.
@Composable
fun <T> rememberMutableStateListOf(vararg elements: T): SnapshotStateList<T> {
return rememberSaveable(
saver = listSaver(
save = { stateList -> stateList.toList() },
restore = { list -> list.toMutableStateList() }
)
) {
elements.toList().toMutableStateList()
}
}
The problem is, it works with all devices, but not with tablet. Once the screen is rotated, it shows no elements in, e.g. from portrait to landscape. But when rotating back from landscape to portrait the list contains elements like before.
I do not have a physical device and use the Android emulator (resizable).
What might be the problem?
EDIT:
That's not only for rememberMutableStateListOf
, but also other saveable variables like
var done by rememberSaveable { mutableStateOf(false) }
No saveable variable survives screen rotation, only ViewModel
.
本文标签: mutablelistWhy does rememberMutableStateListOf doesn39t work with TabletStack Overflow
版权声明:本文标题:mutablelist - Why does rememberMutableStateListOf doesn't work with Tablet? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741775083a2396975.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论