• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Keyboard events for EditText not reaching my event handler.

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).



and the associated layout:
 
Adam Schweitzer
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can someone help me with this? I don't understand why this doesn't work - even the HelloFormStuff tutorial uses essentially the same code..
 
Ranch Hand
Posts: 56
Android Mac Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't find any bugs in the code and, at least over here, it's working as expected.
Everything I type in the first EditText field is duplicated in the second one.
 
Adam Schweitzer
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Misha van Tol
Ranch Hand
Posts: 56
Android Mac Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic