Enable and disable the input method of the Android Program

Source: Internet
Author: User

Today, I sorted out the operations on the input method in Android:

1. Open the input method window:


[Java]
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 );

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); 2. Close the entry/exit window.


[Java]
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> // receives the edited text or other views input by the soft keyboard. </DIV> <P style =" LINE-HEIGHT: 26px; FONT-FAMILY: Arial; COLOR: rgb (51, 51); FONT-SIZE: 14px "> inputMethodManager </P> <DIV style =" LINE-HEIGHT: 26px; FONT-FAMILY: Arial; COLOR: rgb (51, 51); FONT-SIZE: 14px "id = _ mcePaste>. showSoftInput (submitBt, InputMethodManager. SHOW_FORCED); </DIV>

NputMethodManager inputMethodManager = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );

InputMethodManager. hideSoftInputFromWindow (OpeListActivity. this. getCurrentFocus (). getWindowToken (),

InputMethodManager. HIDE_NOT_ALWAYS); // accept the edited text input by the soft keyboard or other views, such as inputMethodManager. showSoftInput (submitBt, InputMethodManager. SHOW_FORCED); 3. Disable the input method if it is not enabled.


[Java]
InputMethodManager m = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
 
M. toggleSoftInput (0, InputMethodManager. HIDE_NOT_ALWAYS );

InputMethodManager m = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );

M. toggleSoftInput (0, InputMethodManager. HIDE_NOT_ALWAYS); 4. obtain the status of the input method.


[Java]
InputMethodManager imm = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
Boolean isOpen = imm. isActive ();
// If isOpen returns true, it indicates that the input method is enabled.

InputMethodManager imm = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE );
Boolean isOpen = imm. isActive ();
// If isOpen returns true, it indicates that the input method is enabled.

 

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.