admin管理员组文章数量:1291799
Is it possible to display a placeholder on the detail pane of a ListDetailPaneScaffold
when still no item from the list has been selected? I'm displaying a route in a map when an item is selected, and whould be preferable to display an empty map on the detail pane before any item has been selected. Displaying a white empty space seems not good. I can't find how to achieve this on docs.
ListDetailPaneScaffold(
modifier = Modifier.fillMaxSize(),
directive = navigator.scaffoldDirective,
value = navigator.scaffoldValue,
listPane = {
AnimatedPane(modifier = Modifier.fillMaxWidth(0.1f)) {
LinesList(
lines = uiState.lines,
selectedIndex = uiState.lines.indexOf(uiState.selectedLine),
onItemClick = { index ->
// Navigate to the detail pane with the passed item
navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, index)
},
)
}
},
detailPane = {
AnimatedPane {
// Show the detail pane content if selected item is available
navigator.currentDestination?.content?.let { index ->
val selectedLine = uiState.lines[index]
vm.selectLine(selectedLine)
Map(selectedItem = uiState.selectedLine)
}
}
},
)
Is it possible to display a placeholder on the detail pane of a ListDetailPaneScaffold
when still no item from the list has been selected? I'm displaying a route in a map when an item is selected, and whould be preferable to display an empty map on the detail pane before any item has been selected. Displaying a white empty space seems not good. I can't find how to achieve this on docs.
ListDetailPaneScaffold(
modifier = Modifier.fillMaxSize(),
directive = navigator.scaffoldDirective,
value = navigator.scaffoldValue,
listPane = {
AnimatedPane(modifier = Modifier.fillMaxWidth(0.1f)) {
LinesList(
lines = uiState.lines,
selectedIndex = uiState.lines.indexOf(uiState.selectedLine),
onItemClick = { index ->
// Navigate to the detail pane with the passed item
navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, index)
},
)
}
},
detailPane = {
AnimatedPane {
// Show the detail pane content if selected item is available
navigator.currentDestination?.content?.let { index ->
val selectedLine = uiState.lines[index]
vm.selectLine(selectedLine)
Map(selectedItem = uiState.selectedLine)
}
}
},
)
Share
Improve this question
asked Feb 13 at 12:51
NullPointerExceptionNullPointerException
37.7k80 gold badges230 silver badges403 bronze badges
1 Answer
Reset to default 0You already properly distinguish between a loaded entry and the unselected state by only applying the details content when navigator.currentDestination?.content
is not null.
You just need to add your placeholder in the case it is null:
navigator.currentDestination?.content?.let { index ->
// details of selected item
} ?: DetailsPlaceHolder()
本文标签: androidDetail placeholder in ListDetailPaneScaffoldStack Overflow
版权声明:本文标题:android - Detail placeholder in ListDetailPaneScaffold? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741539942a2384261.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论