How to Hide keyboard when activity starts

I have an activity with lots of edittext. whenever I load that activity, the keyboard appears and eats half of the screen which makes that activity's look bad. So is there any way to hide keyboard when I load that activity.


in your onCreate() use this..


In your AndroidManifest.xml add the attribute android:windowSoftInputMode:

<activity android:name="your.package.ActivityName"
      android:windowSoftInputMode="stateHidden"  />

Add this two line in your activity's XML file in the RootLayout i.e. either relative or linear(whatever you have taken) :


Add this line in activity manifests file



You can do this using intputmethodmangare... using the following code..

InputMethodManager imm = (InputMethodManager)getSystemService(

imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);

Put this code on the onCrete function:

new Handler().postDelayed(new Runnable() { @Override public void run() { InputMethodManager imm =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); view.clearFocus(); }}, 50);

where view is your EditText

The runnable is because the code might be executed before the editText is rendered.

Need Your Help

Measuring and monitoring Node.JS server performance

performance node.js monitoring maintenance

I'm new to Node.JS, already Googled for aswers but there is a lot of ways of doing this.

Way to verify kernel was executed in CUDA


When I call a kernel with ill-set parameters (e.g. more than 512 threads per block) or when the operations inside it require more than what my device has to offer (e.g. too many registers) the kern...