I added an OnKeyListener to an EditText widget.. the problem is, this event handler never gets called when tying in the widget. And I don't understand why. Can someone explain what I'm doing wrong?
Here is some sample code to illustrate what I'm trying to do. All it is supposed to do is fill a second text box with the value of the first. But it doesn't. (Clicking on the button, though, does function as desired - and the two event handlers have the same code).
I should elaborate a bit.
In the emulator, if you have not clicked on the first textbox prior to typing, it works as intended. If you click on the textbox and then type, it does not.
When deployed on a real device, it does not work either.
I have worked around this issue by using a TextWatcher (via addTextChangedListener() method of EditText) instead of an OnKeyListener.. but I have no clue why I am experiencing this behaviour.
I see it happening now, It's a problem (bug) of the soft keyboard. It's working fine with the keyboard using the emulator, but when you use the soft keyboard the listener is only called when you press return or delete. As far a I can see using the TextWatcher is the best workaround.