I want to hide keyboard on click event of a button. Any help would be appreciated
Asked
Active
Viewed 1,319 times
2 Answers
11
to hide the virtual keyboard:
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editView.getWindowToken(), 0);
Nermeen
- 15,570
- 5
- 52
- 68
3
InputMethodManager inputManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
I put this right after the onClick(View v) event.
You need to import android.view.inputmethod.InputMethodManager;
The keyboard hides when you click the button.
KDeogharkar
- 11,502
- 7
- 51
- 93