You can force Android to hide the virtual keyboard using the InputMethodManager, calling
or
hideSoftInputFromWindow
, passing in the token of the window containing your edit field.
This will force the keyboard to be hidden in all situations. In some cases you will want to pass inInputMethodManager imm = (InputMethodManager)getSystemService( Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
InputMethodManager.HIDE_IMPLICIT_ONLY
as the second parameter to ensure you only hide the keyboard when the
user didn't explicitly force it to appear (by holding down menu).or
Also useful for hiding the soft keyboard is:
Or
Official documentation:- http://developer.android.com/reference/android/view/inputmethod/InputMethodManager.html
Sources:- http://stackoverflow.com/questions/1109022/close-hide-the-android-soft-keyboard
This can be used to suppress the keyboard until the user actually touches the edittext view.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Or
Meier's solution works for me too. In my case
the top level of my App is a tabHost and I want to hide the keyword
when switching tabs - I get the window token from the tabHost View.
tabHost.setOnTabChangedListener(new OnTabChangeListener() { public void onTabChanged(String tabId) { InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(tabHost.getApplication
WindowToken(), 0); } }
Official documentation:- http://developer.android.com/reference/android/view/inputmethod/InputMethodManager.html
Sources:- http://stackoverflow.com/questions/1109022/close-hide-the-android-soft-keyboard
0 comments
Thanks for your comment