Android Open and operate on IME (on/off) _android

Source: Internet
Author: User

Today, I sorted out the operation of the input method under Android: specific as follows
First, open the Input Method window:

Copy Code code as follows:

Inputmethodmanager Inputmethodmanager = (inputmethodmanager) getsystemservice (Context.input_method_service);
Edit text or other views that accept soft keyboard input
Imm.showsoftinput (submitbt,inputmethodmanager.show_forced);

second, close access to the Law window
Copy Code code 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>//to accept soft keyboard input edit text or other views </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>

if the input method is open, close, if not open, open
Copy Code code as follows:

Inputmethodmanager m= (Inputmethodmanager) Getsystemservice (Context.input_method_service);
M.togglesoftinput (0, inputmethodmanager.hide_not_always);

four, get Input method open state
Copy Code code as follows:

Inputmethodmanager IMM = (inputmethodmanager) getsystemservice (Context.input_method_service);
Boolean isopen=imm.isactive ();
IsOpen returns True, means the input method opens

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.