I had to figure it out today so I thought I’ll shared it with the world. Say for whatever reason you need to show or to hide virtual (soft) keyboard in your Android app. It’s not very intuitive but can be easily done. Here’s one scenario – you are executing action that places focus into the text field. To my surprise it doesn’t bring up a soft keyboard on MyTouch (or emulator). To actually do so requires the following additional code:
To show:
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);
Popular Posts That You Might Enjoy!
- October 12, 2009 — Samsung’s Customized Keyboard (6)
- September 22, 2009 — App Review: Handcent SMS (4)
- September 21, 2009 — Zeta TYPE Looking for Virtual Keyboard Testers (6)



![Google Chrome Beta for Android Hands-on [Video]](http://www.theandroider.com/wp-content/themes/news-magazine-theme-640/cropper.php?src=/wp-content/plugins/wp-o-matic/cache/6ea29_chrome-logo.png&h=50&w=50&zc=1&q=95)





