Android点击关闭软键盘

//此方法,如果显示则隐藏,如果隐藏则显示
private void hintKbOne() {
InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);   
// 得到InputMethodManager的实例
if (imm.isActive()) {
 // 如果开启
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,
InputMethodManager.HIDE_NOT_ALWAYS);
        
    }
}


//此方法只是关闭软键盘
private void hintKbTwo() {
 InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);           
 if(imm.isActive()&&getCurrentFocus()!=null){
    if (getCurrentFocus().getWindowToken()!=null) {
    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }            
 }
}

Android点击关闭软键盘

相关文章:

  • 2022-12-23
  • 2021-09-08
  • 2021-09-08
  • 2022-01-17
  • 2021-10-13
  • 2021-09-17
  • 2022-12-23
  • 2021-09-28
猜你喜欢
  • 2022-02-03
  • 2021-10-27
  • 2022-12-23
  • 2021-09-08
  • 2022-01-08
  • 2022-12-23
相关资源
相似解决方案