Question

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

Was it helpful?

Solution

to hide the virtual keyboard:

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editView.getWindowToken(), 0);

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top