12

I want to hide keyboard on click event of a button. Any help would be appreciated

user2041902
  • 533
  • 1
  • 6
  • 21

2 Answers2

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