IT関連お悩み解決

Android キーボードを消す方法

Androidアプリで表示されるソフトキーボードを消す方法です。
フォーカスがないとヌルポになるので、ガードしておきます。

 

InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
if (getCurrentFocus() != null) {
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}

page top