How to hide the Android Soft Keyboard


I have a EditText View and I want to hide Android Virtual keyboard whenever the EditText View does not has focus

Answered question

You can also get the complete source code from the example code here –

Changed status to publish

In android you can use InputMethodManager to hide a virtual keyboard. A simple code sample is shown below.

EditText editText = (EditText) findViewById(;  
InputMethodManager inputMethod = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethod.hideSoftInputFromWindow(editText.getWindowToken(), 0);