2016-12-13 18 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); 
} 
関連する問題