Reputation: 570
I've read several answers to similar question but none of them are satisfying. I want to open and close the keyboard whenever I want.
This is what I've found:
Set the following to your activity inside AndroidManifest.xml
android:windowSoftInputMode="stateHidden"
Or in onCreate of your activity's code:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
is this the correct way to do it? I don't understand why there isn't a simple way to open and close it.
Upvotes: 0
Views: 58
Reputation: 11194
InputMethodManager iMM = (InputMethodManager)this.getSystemService(Service.INPUT_METHOD_SERVICE);
Show it via: iMM.showSoftInput(ed, 0);
Hide it via: iMM.hideSoftInputFromWindow(ed.getWindowToken(), 0);
Upvotes: 0