How to remove auto focus/keyboard popup of a field when the screen shows up?

Pentium10 picture Pentium10 · May 23, 2010 · Viewed 76.3k times · Source

I have a screen where the first field is an EditText, and it gains the focus at startup, also popups the numeric input type, which is very annoying

How can I make sure that when the activity is started the focus is not gained, and/or the input panel is not raised?

Answer

Mitul Nakum picture Mitul Nakum · May 23, 2011
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editTextField.getWindowToken(), 0);

or

set activity property in manifest file as below in the application tag

android:windowSoftInputMode="stateHidden"