Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep soft keyboard from opening on activity launch in Android?

Tags:

android

In an Android app, whenever the activity launches, the textbox gets the focus and the soft keyboard pops up automatically. I have tried to stop this by using following line in onCreate method, but it does not work.

((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(EditText.getWindowToken(), 0); 
like image 406
Adnan Avatar asked Jun 14 '10 13:06

Adnan


People also ask

How do I turn off soft keyboard on Android after clicking outside?

Ok everyone knows that to hide a keyboard you need to implement: InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm. hideSoftInputFromWindow(getCurrentFocus(). getWindowToken(), 0);


1 Answers

I know this is old but maybe it will help someone in the future...

I haven't seen anyone suggest "stateHidden"

From the Android docs - android:windowSoftInputMode

Your manifest file would look like:

<activity     ...     android:windowSoftInputMode="stateHidden|adjustResize"     ... > 
like image 87
rf43 Avatar answered Sep 20 '22 13:09

rf43