I have an EditText that I want to monitor KeyEvents for, and I have a listener set up as follows:
mText = (EditText) this.findViewById(R.id.title);
mText.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
final int view = v.getId();
switch (view) {
case R.id.title:
Log.d(LOG_TAG, "key handled");
break;
}
return false;
}
});
My problem is that when the EditText is being typed into using the virtual keyboard, the only key press that triggers the logging is the backspace key. I've verified that all other keypresses aren't even triggering onKey()
. I'm sure this is something simple, but didn't find anything on SO that seemed to deal with this.
Thanks,
Paul
Try using addTextChangedListener(TextWatcher watcher)
defined here with it you can handle the physical and the soft keyboard.
I hope it helps