Reputation: 113
I have a ExposedDropdownMenu and the first Menu item is a OutlinedTextField that filters the menu items. It's work fine in VM and physical keyboard but it doesn't show software keyboard on VM and physical device. Here is the code:
ExposedDropdownMenuBox(
expanded = isExpanded,
onExpandedChange = {
isExpanded = !isExpanded
},
modifier = modifier
) {
OutlinedTextField(
value = text,
onValueChange = {
},
readOnly = true,
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = isExpanded) },
modifier = modifier.menuAnchor(),
colors = TextFieldDefaults.colors().copy(
focusedContainerColor = Color.Transparent,
unfocusedContainerColor = Color.Transparent
),
label = label,
isError = isError,
supportingText = supportingText
)
ExposedDropdownMenu(
expanded = isExpanded,
onDismissRequest = { isExpanded = false }
) {
if (isSearchEnabled) {
OutlinedTextField(
value = searchQuery,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 8.dp),
onValueChange = {
searchQuery = it
onSearch(it)
},
trailingIcon = {
Icon(
imageVector = Icons.Default.Search,
contentDescription = ""
)
},
label = { Text(text = "Search") },
colors = TextFieldDefaults.colors().copy(
focusedContainerColor = Color.White,
unfocusedContainerColor = Color.White
)
)
}
values?.forEach {
DropdownMenuItem(text = { Text(text = it.first) }, onClick = {
onOptionSelected(it.first, it.second)
isExpanded = false
},
contentPadding = ExposedDropdownMenuDefaults.ItemContentPadding
)
}
}
}
it gets the focus but only flicking courser and not showing keyboard. appreciate for any help
Upvotes: 0
Views: 61
Reputation: 113
After some experiments, I found that replacing ExposedDropdownMenu
with DropdownMenu
resolves the issue.
Upvotes: 1
Reputation: 11
You have readOnly = true, which prohibits changing the text and therefore the keyboard is not shown
Upvotes: 1