Mental Jetsam

By Peter Finch

Archive for July 19th, 2012

Hiding the Android soft keyboard

Posted by pcfinch on July 19, 2012

This sounded so simple… but it wasn’t as easy as I thought. All I wanted to do was hide the soft keyboard when I was switching (using a ViewFlipper) to a view that did not require it. This is what I ended up doing and it seems to work.

ViewFlipper flipper = (ViewFlipper)this.findViewById(R.id.viewFlipper_main) ; // Any active view will do
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE) ;
imm.hideSoftInputFromWindow(flipper.getApplicationWindowToken(), 0);
flipper.setDisplayedChild(1) ;

Posted in Programming | 1 Comment »