Android EditText, soft keyboard show/hide event?

前端 未结 7 1942
天涯浪人
天涯浪人 2020-11-29 03:43

Is it possible to catch the event that Soft Keyboard was shown or hidden for EditText?

相关标签:
7条回答
  • 2020-11-29 04:40

    You can capture this by overwriting the onConfigurationChanged method of your activity:

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
       super.onConfigurationChanged(newConfig);
    
       if(newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
          ((SherlockFragmentActivity)getActivity()).getSupportActionBar().hide();
       }
       else if(newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES){
          ((SherlockFragmentActivity)getActivity()).getSupportActionBar().show();
       }
    }
    
    0 讨论(0)
提交回复
热议问题