Android HIDE_NOT_ALWAYS, android hide

Source: Internet
Author: User

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?
  1. InputMethodManager imm = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
  2. 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?
  1. InputMethodManager imm = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
  2. Imm. showSoftInput (view, InputMethodManager. SHOW_FORCED );

[Java]View plaincopyprint?
  1. Imm. hideSoftInputFromWindow (view. getWindowToken (), 0); // force hide the keyboard


3. Call to hide the default system input method

[Java]View plaincopyprint?
  1. (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?
  1. InputMethodManager imm = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
  2. Boolean isOpen = imm. isActive (); // If isOpen returns true, the input method is enabled.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.