如何强制outLineTxtFieldValue只接受数字?
例如
用户只能输入数字,不能输入负值。我们可以输入像
这样的数字120
,1
,9
,10012
,
简而言之,我们可以在kotlin中表示positive integers
或natural numbers
组成outlinetextfield
或textfield
TextField(
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number)
仅显示数字键盘:
TextField(
value = textState,
onValueChange = { text ->
textState = text
},
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.NumberPassword
),
visualTransformation = VisualTransformation.None
)