Home  >  Forum  >  Android
Post New Query

How to show and hide soft keyboard in android


joined on
August 12,2015
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.

joined on
January 20,2015
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);
}

joined on
January 20,2015
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



Sitewide-Feb4of4234x60





Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us