Android HIDE_NOT_ALWAYS, android hide
1. method 1 (if the input method is displayed in the window, it is hidden, and otherwise displayed)
[Java]View plaincopyprint?
- InputMethodManager imm = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
- Imm. toggleSoftInput (0, InputMethodManager. HIDE_NOT_ALWAYS );
2. method 2 (view is the view that accepts soft keyboard input, SHOW_FORCED indicates forced display)
[Java]View plaincopyprint?
- InputMethodManager imm = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
- Imm. showSoftInput (view, InputMethodManager. SHOW_FORCED );
[Java]View plaincopyprint?
- Imm. hideSoftInputFromWindow (view. getWindowToken (), 0); // force hide the keyboard
3. Call to hide the default system input method
[Java]View plaincopyprint?
- (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE). Invoke (WidgetSearchActivity. this. getCurrentFocus (). getWindowToken (), InputMethodManager. HIDE_NOT_ALWAYS); (getwidsearchactivity is the current Activity)
4. Obtain the enabled status of the input method.
[Java]View plaincopyprint?
- InputMethodManager imm = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
- Boolean isOpen = imm. isActive (); // If isOpen returns true, the input method is enabled.