Dialog
Interrupts users with urgent information, decisions, or tasks.
Properties
Preview
Generated Code
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Info
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.vector.ImageVector
@Composable
fun MyAlertDialog() {
val openDialog = remember { mutableStateOf(true) }
if (openDialog.value) {
AlertDialog(
onDismissRequest = { openDialog.value = false },
icon = { Icon(Icons.Filled.Info, contentDescription = null) },
title = {
Text(text = "Use Google's location service?")
},
text = {
Text(text = "Let Google help apps determine location. This means sending anonymous location data to Google, even when no apps are running.")
},
confirmButton = {
TextButton(
onClick = {
openDialog.value = false
}
) {
Text("Agree")
}
},
dismissButton = {
TextButton(
onClick = {
openDialog.value = false
}
) {
Text("Disagree")
}
},
)
}
}