【发布时间】:2021-01-15 21:40:26
【问题描述】:
我的用例是我有一个表单,其中一些字段是手动填写的,而另一些则将用户带到一个屏幕,在那里他们可以在一个大列表中搜索他们想要的值。仅接受用户输入的字段工作正常,但是当我尝试将属性 readOnly = true 添加到 TextField Composable 时,出现以下错误:
None of the following functions can be called with the arguments supplied.
TextField(TextFieldValue, (TextFieldValue) → Unit, Modifier = ..., TextStyle = ..., (() → Unit)? = ..., (() → Unit)? = ..., (() → Unit)? = ..., (() → Unit)? = ..., Boolean = ..., VisualTransformation = ..., KeyboardOptions = ..., Boolean = ..., Int = ..., (ImeAction, SoftwareKeyboardController?) → Unit = ..., (SoftwareKeyboardController) → Unit = ..., InteractionState = ..., Color = ..., Color = ..., Color = ..., Color = ..., Shape = ...) defined in androidx.compose.material
TextField(String, (String) → Unit, Modifier = ..., TextStyle = ..., (() → Unit)? = ..., (() → Unit)? = ..., (() → Unit)? = ..., (() → Unit)? = ..., Boolean = ..., VisualTransformation = ..., KeyboardOptions = ..., Boolean = ..., Int = ..., (ImeAction, SoftwareKeyboardController?) → Unit = ..., (SoftwareKeyboardController) → Unit = ..., InteractionState = ..., Color = ..., Color = ..., Color = ..., Color = ..., Shape = ...) defined in androidx.compose.material
我假设此错误与我的参数与为 TextField 提供的覆盖不匹配有关,但我似乎无法在文档中找到任何关于我应该如何使用此属性的内容,而不是简单地为其提供Boolean 值。我正在寻找 here 的文档。
代码是:
TextField(
value = statefulValue,
onValueChange = {},
label = {
Text("Label")
},
placeholder = {
Text("Search items")
},
trailingIcon = {
Icon(
imageVector = Icons.Filled.Search
)
},
readOnly = true
)
我正在使用 Compose Material 包的 androidx.compose.material:material:1.0.0-alpha09 版本,而我的其余 compose 依赖项也使用 alpha09。
【问题讨论】: