Untitled

 avatar
unknown
plain_text
19 days ago
1.9 kB
5
Indexable
  Text(text = "Direction:", color = Color.Black)
        var expanded by remember { mutableStateOf(false) }

        ExposedDropdownMenuBox(expanded = expanded, onExpandedChange ={
            expanded = !expanded
        }
        ) {
            OutlinedTextField(
                value = direction,
                onValueChange = {},
                readOnly = true,
                modifier = Modifier
                    .fillMaxWidth()
//                    .padding(0.dp)
                    .clickable { expanded = true },

                trailingIcon = {
                    ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded)
//                     Icon(
//                         painter = painterResource(id = R.mipmap.ic_dropdown),
//                         contentDescription = null
//                    )
                },

                colors = OutlinedTextFieldDefaults.colors(
                    focusedContainerColor = Color.LightGray,
                    unfocusedContainerColor = Color.LightGray,
                    cursorColor = Color.Black,
                    focusedBorderColor = Color.DarkGray,
                    unfocusedBorderColor = Color.DarkGray,
                )
            )


            ExposedDropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }, modifier = Modifier.fillMaxWidth()
            ) {
                directions.forEach { selection ->
                    DropdownMenuItem(
                        text = { Text(selection)},
                        onClick = {
                            direction = selection
                            expanded = false
                        }
//                        {
//                            Text(text = direction)
//                        }
                    )
                }
            }
        }
Editor is loading...
Leave a Comment