I'm trying to set input type of the TextField as a Binary but there is no KeyboardOptions KeyboardType as Binary.
So how can I accomplish this ?
TextField(
value = text,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
onValueChange = {
text = it
},
label = { Text("Enter Binary") }
)
CodePudding user response:
There is no such input options, but you can filter invalid values out:
TextField(
value = text,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
onValueChange = {
text = it.filter { it == '0' || it == '1' }
},
label = { Text("Enter Binary") }
)