3

I want to know how to hide and (after certain action) then show the Android Soft keyboard. This is fairly easy with API Level 24, however I am targeting API level 23.

Following is my code which works for API Level 24:

// to hide
getSoftKeyboardController().setShowMode(SHOW_MODE_HIDDEN);

// to show
getSoftKeyboardController().setShowMode(SHOW_MODE_AUTO);

How do I do same with API Level 23?

avi
  • 8,686
  • 10
  • 45
  • 81

1 Answers1

-1

Hide keyboard

public static void hideKeyboardFrom(Context context, View view) {
      InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
Narendra Sorathiya
  • 3,660
  • 2
  • 33
  • 36