How to programmatically hide Android soft keyboard code example
Example: How to programmatically hide Android soft keyboard
private void closeSoftKeyboard()
{
//If using a fragment use getActivity().getCurrentFocus()
View v = this.getCurrentFocus();
// If Soft Keyboard is visible, it will be hide
if (v != null) {
//If using a fragment use getActivity().getSystemService(...)
InputMethodManager inputManager
= (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
}