(Android) Proven Code to Hide Soft Keyboard

  • 0
Programmatically:
this.getWindow().setSoftInputMode(
    WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
XML:
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:descendantFocusability="beforeDescendants"
Programatically 2:
    public void hideSoftKeyboard(){
        if(getActivity().getCurrentFocus() != null){
            InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), 0);
        }
    }

No comments:

Post a Comment

Kalau mau komen, pada "Beri Komentar Sebagai : "
Pilih "Name/URL", atau pakai akun google kalau punya.