提问人:Robert 提问时间:11/9/2023 更新时间:11/9/2023 访问量:28
jetpack compose 向后滑动导航不记得 PrimaryTabRow selectedIndex
jetpack compose swipe back for navigation does not remember PrimaryTabRow selectedIndex
问:
我发现当我导航到一个页面然后向后滑动时,不记得了,并且总是以 0 结束。有没有办法在更改视图时记住索引值?谢谢!selectedTabIndex
var tabIndex by remember { mutableStateOf(0) }
val tabs = listOf("Never Give", "You Up")
PrimaryTabRow(
selectedTabIndex = tabIndex
) {
tabs.forEachIndexed { index, title ->
Tab(text = { Text(title) },
selected = tabIndex == index,
onClick = { tabIndex = index }
)
}
}
when (tabIndex) {
0 -> SomeView()
1 -> AnotherView()
}
答: 暂无答案
评论
rememberSaveable
rememberSaveable
remember