Is it possible to catch the event that Soft Keyboard was shown or hidden for EditText?
A:
We can toggle the on-screen keyboard using the code below.
InputMethodManager inputMgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMgr.toggleSoftInput(0, 0);
To show Soft Keyboard for EditText:
EditText editText = (EditText) findViewById(R.id.myEdit);
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// only will trigger it if no physical keyboard is open
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
And to hide:
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(editText.getWindowToken(), 0);
Refer this links: http://www.androidpeople.com/android-hide-virtual-keyboard-through-code/ , http://stackoverflow.com/questions/1109022/how-to-close-hide-the-android-soft-keyboard
PM - Paresh Mayani
2010-09-25 13:07:52
Thanks, but I'm not asking how to control the keyboard to be shown or hidden. I just want to catch the event when the system shows the keyboard.
shkim
2010-09-25 17:05:18
+2
A:
There actually isn't such an event to catch. The IME is simply showing and hiding its window; the feedback you get from this is the window manager causing your own window's content to resize if you have put it in resize mode.
hackbod
2010-09-25 17:50:44