Skip to content

Instantly share code, notes, and snippets.

@manojbhadane
Last active August 5, 2023 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manojbhadane/7526ce6dc466ee6f489087cac6f33d67 to your computer and use it in GitHub Desktop.
Save manojbhadane/7526ce6dc466ee6f489087cac6f33d67 to your computer and use it in GitHub Desktop.
val options = listOf("Food", "Bill Payment", "Recharges", "Outing", "Other")
var expanded by remember { mutableStateOf(false) }
var selectedOptionText by remember { mutableStateOf(options[0]) }
@Composable
ExposedDropdownMenuBox(
expanded = expanded,
onExpandedChange = {
expanded = !expanded
}
) {
TextField(
readOnly = true,
value = selectedOptionText,
onValueChange = { },
label = { Text("Categories") },
trailingIcon = {
ExposedDropdownMenuDefaults.TrailingIcon(
expanded = expanded
)
},
colors = ExposedDropdownMenuDefaults.textFieldColors()
)
ExposedDropdownMenu(
expanded = expanded,
onDismissRequest = {
expanded = false
}
) {
options.forEach { selectionOption ->
DropdownMenuItem(
onClick = {
selectedOptionText = selectionOption
expanded = false
}
) {
Text(text = selectionOption)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment