Function

item

Adds an item to the list of text context menu components.

AppendItemToTextContextMenuAndroid

@Sampled
@Composable
fun AppendItemToTextContextMenuAndroid() {
    val textFieldState = rememberTextFieldState()
    val label = stringResource(R.string.context_menu_clear)
    BasicTextField(
        state = textFieldState,
        modifier =
            Modifier.appendTextContextMenuComponents {
                separator()
                item(
                    key = ClearKeyDataObject,
                    label = label,
                    leadingIcon = R.drawable.ic_sample_vector,
                ) {
                    textFieldState.clearText()
                    close()
                }
                separator()
            },
    )
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: