0

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") }
    )
Enca
  • 3
  • 3

1 Answers1

0

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") }
)
Francesc
  • 25,014
  • 10
  • 66
  • 84