Reputation: 1776
I am a beginner of Jetpack compose. Now in my app screen, an AlertDialog
is used to show some information to user.
According to doc, onDismissRequest
is invoked when the user clicks outside the dialog or on the back button.
But I just want to dismiss it when back button is pressed, but not dissmiss when outside touched, how can I distinguish between them?
Upvotes: 5
Views: 2098
Reputation: 14857
I just want to dismiss it when the back button is pressed, but not dismiss when outside touched
Use the properties
attribute in AlertDialog
like this.
AlertDialog(
properties = DialogProperties(
dismissOnClickOutside = false,
dismissOnBackPress = true,
),
)
Upvotes: 8