Hide keyboard when navigating from a fragment to another

Put the code that hides the keyboard in your “save button” click listener, and use this method to hide the keyboard:

    public static void hideKeyboard(Activity activity) {
        InputMethodManager inputManager = (InputMethodManager) activity
        .getSystemService(Context.INPUT_METHOD_SERVICE);

        // check if no view has focus:
         View currentFocusedView = activity.getCurrentFocus();
         if (currentFocusedView != null) {
             inputManager.hideSoftInputFromWindow(currentFocusedView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
         }
     }

Leave a Comment

techhipbettruvabetnorabahisbahis forumu