Android Auto Eject soft keyboard (input keyboard)

Source: Internet
Author: User

Many applications for an interface such as access to the search interface or modify information and so on, in order to user experience should automatically eject the soft keyboard instead of letting the user actively click the input box to pop up (because the user entered the interface is necessarily to change information). This effect is achieved as follows:[Code]java Code
     EditText  editText.setFocusable(true);
        editText.setFocusableInTouchMode(true);
        editText.requestFocus();
InputMethodManager inputManager =
                    (InputMethodManager)editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.showSoftInput(editText,0);

The first step is to request focus on the specified input box. Then call the input manager to eject the soft keyboard.

Warning: If you just jump to a new interface to eject the soft keyboard, the above code may not eject the soft keyboard because the interface is loaded completely. A soft keyboard such as 998 milliseconds (which ensures that the interface's data is loaded) should be properly delayed. The instance code is as follows:

[Code]java Code:
Timer timer =newTimer();
     timer.schedule(newTimerTask()
     {
         publicvoidrun() 
         {
             InputMethodManager inputManager =
                 (InputMethodManager)editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
             inputManager.showSoftInput(editText,0);
         }
     },  
         998);
article from: http://www.devdiv.com/home.php?mod=space&uid=65729&do=blog&id=11847
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.