如何强制EditText只接受数字在撰写kotlin?



如何强制outLineTxtFieldValue只接受数字?

例如

用户只能输入数字,不能输入负值。我们可以输入像

这样的数字1201,9,10012,

简而言之,我们可以在kotlin中表示positive integersnatural numbers组成outlinetextfieldtextfield

TextField(
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number)

仅显示数字键盘:

TextField(
value = textState,
onValueChange = { text ->
textState = text
},
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.NumberPassword
),
visualTransformation = VisualTransformation.None
)

最新更新