问题
I need to identify the event of back press which hide the softkeyboard
I have tested by override following methods
- onKeydown
- onBackPressed
- onConfigurationChanged
- dispatchKeyEvent
But the controller is not reaching there
回答1:
Use dispatchKeyEventPreIme in subclassed EditText view:
@Override
public boolean dispatchKeyEventPreIme(KeyEvent event) {
if(KeyEvent.KEYCODE_BACK == event.getKeyCode()) {
//do what you need here
}
return super.dispatchKeyEventPreIme(event);
}
来源:https://stackoverflow.com/questions/6069436/soft-keyboard-hide-on-backpress