I’m trying to get edit text to behave in this way:
User can input maximum of 10 characters, when focus is lost from edit text the current text gets formatted like: 0123456789 -> 0 1 2 3 4 5 6 7 8 9.
So the edit text itself can have up to 19 characters. After the focus is gained again user cannot input before he/she removes characters.
Currently I have been hacking the text with TextWatcher and the solution doesn’t look pretty (needed flags,handler and runnable). So any ideas if there are some nice ways to do this, maybe overriding some super class methods or something like that?
Br,
Niko
I think you can still implement
TextWatcherto let user enter just 10 characters. Whenever user enters 10 characters, set thatEditTextto non-editable. And also set OnFocusChangeListener to it. So whenever it looses focus, change its text and add space after each character except for the last one.