Search code examples
androidkeyboardpopupandroid-softkeyboard

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


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?


Solution

  • 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"