0

Is it possible to limit the user to type only some characters on the keyboard. However, I should be able to add any disallowed character programmatically.

For instance, The user will be allowed to type only the following digits 'A','B' and 'C'. This can be done from the xml code as follows:

< EditText
    ...
    android:digits="ABC" />

However, I want to be able to add a number in that EditText programmatically. Is this possible in Android?

HiddenDroid
  • 1,440
  • 4
  • 14
  • 27
  • _I want to be able to add a number in that EditText programmatically_. Why not `android:digits="ABC123"`? It should work. – Abhi Mar 30 '18 at 19:10
  • 1
    Might [this](https://stackoverflow.com/a/45454342/3290339) help?... – Onik Mar 30 '18 at 19:30
  • @Abhi I don't wanna allow the user to type the numbers. That's why I am not adding them to the allowed digits – HiddenDroid Mar 30 '18 at 19:54
  • @Onik Well, it doesn't answer literally my question. It's mostly a workaround for that. But I've found there something that could help. It seems like there's no way in the Android to handle this case apart from listening to the changes and behaving correspondingly. Thank's for your answer – HiddenDroid Mar 30 '18 at 19:58

0 Answers0