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 ); |
|
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.schedule( new TimerTask() |
|
InputMethodManager inputManager = |
|
(InputMethodManager)editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); |
|
inputManager.showSoftInput(editText, 0 ); |
article from: http://www.devdiv.com/home.php?mod=space&uid=65729&do=blog&id=11847