2016-12-13 2 views

ответ

0

Используйте этот

View view = this.getCurrentFocus(); 
if (view != null) { 
    InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0); 
} 
0

попробовать этот метод, чтобы скрыть клавиатуру:

public void hideKeyboard(Activity activity) { 
     try { 
      InputMethodManager inputManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); 
      if (inputManager!=null) { 
       if (activity.getCurrentFocus() == null) 
        return; 
       if (activity.getCurrentFocus().getWindowToken() == null) 
        return; 
       inputManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); 
      } 
     } catch (Exception hideKeyboardException) { 
      // handle exception here 
     } 
    } 

Если у вас нет какой-либо деятельности, то удалить объект формы активности этого метода.

0

Я не уверен, может быть, это поможет

public void hideSoftKeyboard() { 
    View view = this.getCurrentFocus(); 
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0); 
}