Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Hide Soft keyboard in android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 529
    Comment on it

    Below I am writing a method that will hide the soft keyboard in android.

    I just use hideSoftInputFromWindow() method of InputMethodManager in this method.


    public static void hideKeyboard(Activity activity) {
            //start with an 'always hidden' command for the activity's window
            activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
            //now tell the IMM to hide the keyboard FROM whatever has focus in the activity
            InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
            View currentFocusedView = activity.getCurrentFocus();
            if (currentFocusedView != null) {
                inputMethodManager.hideSoftInputFromWindow(currentFocusedView.getWindowToken(), 0);
            }
        }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: