Android Onkey W/ Virtual Keyboard
I am catching keyboard events/presses using the onKey method: public boolean onKey(View arg0, int arg1, KeyEvent arg2) { //do something return false; } This fires off just
Solution 1:
If it's an EditText, see if you can use a TextChangedListener instead.
myEditText.addTextChangedListener(new TextWatcher(){
publicvoidafterTextChanged(Editable s) {}
publicvoidbeforeTextChanged(CharSequence s, int start, int count, int after) {}
publicvoidonTextChanged(CharSequence s, int start, int before, int count) {
//do stuff
}
});
Solution 2:
Virtual keypresses are delivered directly to the selected view, they don't propagate through parent views like hardware keypresses. Are you overriding onKey on something other than the EditText/List/Whatever that's getting keypresses? (the thing you click on to get the virtual keyboard)
Solution 3:
myEditText.addTextChangedListener(new TextWatcher(){
publicvoidafterTextChanged(Editable s) {}
publicvoidbeforeTextChanged(CharSequence s, int start, int count, int after) {}
publicvoidonTextChanged(CharSequence s, int start, int before, int count) {
//do stuff
}
});
Post a Comment for "Android Onkey W/ Virtual Keyboard"