Search code examples
androidandroid-softkeyboardandroid-keypad

How to close momentarily the android keyboard whatever EditText currently active


I have a form with various EditText and a confirm button, I need that when the user click confirm whatever is the EditText that is currently used the keyboard will be momentarily closed, but if the user try to edit again one of the EditText the keyboard appears again.

How could I do this without add tons of codelines to control each EditText separately?


Solution

  • use simply the InputMethodManager

    this way

    InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);