[英]I want to set a value in textField and not being able to change this value, only possible to insert new values. (kotlin)
我有一个注册表单,当我在输入时选择一个特定的选项时,这个表单的一个 textField 会收到一个无法更改的值,只能在这个 textField 中输入其他值。
If you want to have a text field only the app can update (and the user can't type into), use a TextView
.如果您想要一个只有应用程序可以更新的文本字段(并且用户不能输入),请使用TextView
。
If you want them to be able to type into it, but you want to be able to set a value and "lock" it so they can't edit it anymore, you can use an EditText
and do enabled = false
.如果您希望他们能够输入它,但您希望能够设置一个值并“锁定”它以便他们无法再编辑它,您可以使用EditText
并执行enabled = false
。 That also greys out the field - if you don't want that, you can do inputType = EditorInfo.TYPE_NULL
to prevent the keyboard from appearing.这也会使该字段变灰 - 如果您不希望这样,您可以执行inputType = EditorInfo.TYPE_NULL
以防止键盘出现。
If you want a fixed set of options that the user can choose from, you can use an AutoCompleteTextView
or the Material Components equivalent如果您想要用户可以选择的一组固定选项,您可以使用AutoCompleteTextView
或等效的 Material Components
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.