【发布时间】:2021-11-02 22:18:27
【问题描述】:
我需要一个在 jetpack compose 中使用如下掩码的文本字段:NNNNN-NNN 其中 N 是从 0 到 9 的整数。我需要我的可组合函数在 OutlinedTextField 中有这个掩码:
@Composable
private fun EditTextField(
labelText: String,
value: String,
keyboardType: KeyboardType = KeyboardType.Text,
onValueChanged: (String) -> Unit
) {
OutlinedTextField(
modifier = Modifier.padding(top = 8.dp),
label = { Text(text = labelText) },
keyboardOptions = KeyboardOptions(keyboardType = keyboardType),
value = value,
onValueChange = onValueChanged
)
}
【问题讨论】:
-
到目前为止你有什么尝试?
-
你好朋友,我刚刚用我的代码的 sn-p 更新了这个问题,
EditTextField是我的一个文本字段,我需要它来将此掩码应用于OutlinedTextField,即compose 的内部函数。
标签: android android-jetpack-compose android-jetpack-compose-text android-compose-textfield