I need to let the user enter times in format hh:mm, but because of the issue 28132 I can’t use
<EditText ... android:inputType="time">
I thought I’d accept any separator, e.g., something like hh mm or hh.mm, but such characters can’t be typed either (logical as they don’t belong in time; colon does but is missing from the keyboard). Changing the type to text would work, but the text keyboard is not as good for typing.
So I thought about removing the colon just before the edit starts and putting it back when it ends, but I don’t know how to recognize these events. addTextChangedListener allows to track all fine grained changes, but I don’t think it makes sense to change the text during the time it gets edited, I’d rather need events like editStarts and editEnds, corresponding with showing and hiding the keyboard. Are they such events?
What workaround for this bug would you recommend?
You should use an InputFilter for your TextView and validate whether the input is of type Time.
Since TimeKeyListener also implements a InputFilter.
You could probably use
EDIT:
Or you could even custom time key listener with . as a accepted character
Now it’s also easy to replace the alternate separator (dot) by colon like follows: