I'm trying to catch onKey events from a soft keyboard. however, on开发者_开发问答ly few keys fire the onKey event (Delete, back, etc.). not regular characters. anyone know why?
If you're trying to capture normal keystrokes from an EditText view, you'll need to use the following method to listen for key presses. Your onTextChanged method will get fired on each keypress allowing you to do whatever you need to do.
mEditText.addTextChangedListener(new TextWatcher(){
@Override
public void afterTextChanged(Editable editable){
}
@Override
public void beforeTextChanged(CharSequence text, int start, int count, int after){
}
@Override
public void onTextChanged(CharSequence arg0, int start, int before, int count) {
//doStuff
}
});
精彩评论