-1
public static void hideKeyboard(Activity activity) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);

    View view = activity.getCurrentFocus();

    if (view == null) {
        view = new View(activity);
    }
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

Its not working....!!! When I Click on edittext it will open the keyboard after that when i click another button keyboard is not hiding..

1 Answers1

0

Try calling setShowSoftInputOnFocus(false) on the EditText's instance.

Example:

EditText editText = (EditText) findViewById(R.id.editText);
editText.setShowSoftInputOnFocus(false);

XML :

android:editable="false"
android:windowSoftInputMode="stateAlwaysHidden"
android:inputType="none"
mariuss
  • 1,177
  • 2
  • 14
  • 30