Input box and keyboard pop-up (input method status and Control)

Source: Internet
Author: User

1. Open the input method window:

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 input entry window

Inputmethodmanager = (inputmethodmanager)

Getsystemservice (context. input_method_service); inputmethodmanager. hidesoftinputfromwindow (opelistactivity. this. getcurrentfocus (). getwindowtoken (), inputmethodmanager. hide_not_always); // accepts the edited text or other views input by the keypad. showsoftinput (submitbt, inputmethodmanager. show_forced );

 

3. If the input method is enabled, the function is disabled. If the input method is not enabled, the function is enabled.

InputMethodManager m=(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);

 

4. obtain the status of the input method.

Inputmethodmanager Imm = (inputmethodmanager) getsystemservice (context. input_method_service); Boolean isopen = Imm. isactive (); If isopen returns true, it indicates that the input method is enabled.

Example:

Config. Java

public static void showSoftInput(final EditText edittext) {        Timer timer = new Timer();        timer.schedule(new TimerTask() {            public void run() {                InputMethodManager inputManager =                (InputMethodManager) edittext.getContext().getSystemService(                        Context.INPUT_METHOD_SERVICE);                inputManager.showSoftInput(edittext, 0);            }        }, 400);    }

Xxactivity. Java

Config.showSoftInput(etUserName);

 

Input box and keyboard pop-up (input method status and Control)

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.