[Turn]android automatically eject soft keyboard (input keyboard)

Source: Internet
Author: User

Transferred from: http://www.devdiv.com/home.php?mod=space&uid=65729&do=blog&id=11847

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:
1      EditText  edittext.setfocusable (true); 2         Edittext.setfocusableintouchmode (true); 3         Edittext.requestfocus (); 4 Inputmethodmanager inputmanager =5                    (Inputmethodmanager) Edittext.getcontext (). Getsystemservice (context.input_method_service); 6                 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:
1Timer timer =NewTimer ();2Timer.schedule (NewTimerTask ()3      {4          5           Public voidRun ()6          {7Inputmethodmanager InputManager =8 (Inputmethodmanager) Edittext.getcontext (). Getsystemservice (Context.input_method_service);9Inputmanager.showsoftinput (editText, 0);Ten          } One           A      }, -998);

[Turn]android automatically eject soft keyboard (input keyboard)

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.