Back to project page BestBoard.
The source code is released under:
MIT License
If you think the Android project BestBoard listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package digitalgarden.magicmerlin.utils; /*from w w w. ja va 2s .c o m*/ import android.app.*; import android.view.*; import android.view.inputmethod.*; import digitalgarden.magicmerlin.scribe.*; public class Keyboard { // http://stackoverflow.com/a/17789187; tbbi is j lehet, ez els?re is m?kdtt public static void hide(Activity activity) { if (activity == null) { Scribe.error("Hide-keyboard: activity is missing!!"); return; } //start with an 'always hidden' command for the activity's window activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); Scribe.debug("Hide-keyboard: SOFT_INPUT_STATE_ALWAYS_HIDDEN"); //now tell the IMM to hide the keyboard FROM whatever has focus in the activity InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); View cur_focus = activity.getCurrentFocus(); if(cur_focus != null) { inputMethodManager.hideSoftInputFromWindow(cur_focus.getWindowToken(), 0); Scribe.debug("Hide-keyboard: hideSoftInputFromWindow"); } } }