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)