Issue
I've run this through the debugger a hundred times and stepped into the setContent
over and over. I can't figure out why. No errors given.
Works perfectly on Android phone.
When on a tablet, the entire setContent
code block is skipped over.
This is the piece of the fragment that deals with opening the dialog. Any ideas?
(activity as? MapActivity)?.findViewById<ComposeView>(R.id.map_fragment_container_composeview)
?.setContent {
// Delegate to observe the showDialog state in viewModel
val showDialogState: Boolean by dialog.showDialog.collectAsState()
MdcTheme {
OptionSelectComposeDialog(
show = showDialogState,
onDismiss = dialog::onDialogDismiss,
onConfirm = dialog::onDialogConfirm,
vm = dialog,
)
}
}
Solution
Copying from comments to show the resolution (thanks to @ianhanniballake and @MARSK)
Just to further document for anyone else who comes across, we use a layout folder with the default (phone) layout. There was a separate folder layout-sw600dp that is used for tablets. I got this confused because the files in both folders have the same names, but the composeview needed to be added to both layouts.
Once the composeview
was added to the layout-sw600dp
folder, the issue went away. I also removed many of the nullable (?) markers. Those markers were preventing any errors from appearing.
Update:
Added the nullable ?
markers back in. I'm told it's a good way to future-proof your code.
Answered By - petestmart
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.