Jetpack Compose:禁用与 TextField 的交互 [英] Jetpack Compose: Disable Interaction with TextField

本文介绍了Jetpack Compose:禁用与 TextField 的交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法禁用 Jetpack Compose 的 TextField 的所有交互?

Is there a way to disable all interaction for Jetpack Compose's TextField?

推荐答案

使用 1.0.0 你可以使用 enabled 属性:

With 1.0.0 you can use the enabled attribute:

enabled :控制 TextField 的启用状态.当false时,文本字段将不可编辑也不可聚焦,文本字段的输入将不可选择,视觉文本字段将出现在禁用UI状态

enabled : controls the enabled state of the TextField. When false, the text field will be neither editable nor focusable, the input of the text field will not be selectable, visually text field will appear in the disabled UI state

类似于:

var text by rememberSaveable { mutableStateOf("Text") }

TextField(
    value = text,
    onValueChange = { text = it },
    enabled = false,
    label = { Text("Label") },
    singleLine = true
)

这篇关于Jetpack Compose:禁用与 TextField 的交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆