Home  >  Forum  >  Android
Post New Query

How to show and hide soft keyboard in android



Asked on August 12, 2015
I am new to Android, I am creating a UI with EditText and Button. On click of button I need to hide soft keyboard and later wants to show it.




Replied on August 12, 2015
To hide soft keyboard, use

android:windowSoftInputMode="stateHidden"

as an attribute in AndroidManifest.xml

Programmatically we do it as below

if (view != null) {
    InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}




Replied on August 12, 2015
android:windowSoftInputMode="stateHidden" is the attribute of Activity tag in AndroidManifest.xml

<activity  android:name=".YourActivity" android:windowSoftInputMode="stateHidden">
</activity>


Write Answer




©2019 concretepage.com | Privacy Policy | Contact Us