用于隐藏软件键盘的 KeyEvent 代码?
KeyEvent code for hiding software keyboard?
当在我的虚拟设备上打开软件键盘时,后退按钮会更改功能以在按下时隐藏键盘 - 它不会像隐藏键盘时那样保持 'KEYCODE_BACK'。
这个 "hide" 按钮是否仍然定义为 KeyEvent,或者我是否需要走不同的路线以便在按下时 运行 和 activity?
Android Studio 3.0.1
//setup i was hoping to use, but keycode changes whenever keyboard is shown//
public boolean onKeyDown(int keyCode, KeyEvent event){
if (keyCode == KeyEvent.KEYCODE_BACK)
{
checkEmpty();
}
return false;
}
如 CommonsWare 所述,"the system does not pass that event [back button while keyboard is displayed] to the activity. It just collapses the input method editor (soft keyboard)."
所以不,它不会触发 KeyEvent。
当在我的虚拟设备上打开软件键盘时,后退按钮会更改功能以在按下时隐藏键盘 - 它不会像隐藏键盘时那样保持 'KEYCODE_BACK'。
这个 "hide" 按钮是否仍然定义为 KeyEvent,或者我是否需要走不同的路线以便在按下时 运行 和 activity?
Android Studio 3.0.1
//setup i was hoping to use, but keycode changes whenever keyboard is shown// public boolean onKeyDown(int keyCode, KeyEvent event){ if (keyCode == KeyEvent.KEYCODE_BACK) { checkEmpty(); } return false; }
如 CommonsWare 所述,"the system does not pass that event [back button while keyboard is displayed] to the activity. It just collapses the input method editor (soft keyboard)."
所以不,它不会触发 KeyEvent。