Android program opening and Input Method operations (opening/closing)

Source: Internet
Author: User

Today, I sorted out the operations on the input method in Android:
1. Open the input method window:

Copy codeThe Code is as follows: InputMethodManager inputMethodManager = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
// Accept the edited text or other views input by the soft keyboard
Imm. showSoftInput (submitBt, InputMethodManager. SHOW_FORCED );

Ii. Close the entry/exit window
Copy codeThe Code is as follows: nputMethodManager inputMethodManager = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
InputMethodManager. hideSoftInputFromWindow (OpeListActivity. this. getCurrentFocus (). getWindowToken (),
InputMethodManager. HIDE_NOT_ALWAYS );
<DIV style = "LINE-HEIGHT: 26px; FONT-FAMILY: Arial; COLOR: rgb (51,51, 51 );
FONT-SIZE: 14px "id = _ mcePaste> // accept the edited text or other views entered by the soft keyboard. </DIV>
<P style = "LINE-HEIGHT: 26px; FONT-FAMILY: Arial; COLOR: rgb (51,51, 51); FONT-SIZE: 14px"> inputMethodManager </P>
<DIV style = "LINE-HEIGHT: 26px; FONT-FAMILY: Arial; COLOR: rgb (51,51, 51); FONT-SIZE: 14px" id = _ mcePaste>. showSoftInput (submitBt, InputMethodManager. SHOW_FORCED); </DIV>

3. If the input method is enabled, the function is disabled. If the input method is not enabled, the function is enabled. Copy codeThe Code is as follows: InputMethodManager m = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
M. toggleSoftInput (0, InputMethodManager. HIDE_NOT_ALWAYS );

4. obtain the status of the input method. Copy codeThe Code is as follows: InputMethodManager imm = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
Boolean isOpen = imm. isActive ();
// If isOpen returns true, it indicates that 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.