Possible Duplicate:
Close/hide the Android Soft Keyboard
I'm a beginner, and have written a simple program to find the roots of a quadratic equation. Entering values in the EditText fields works well, because the virtual keypad pops up so that you can enter your numbers. However, the keypad covers the TextView where your results appear. If the user knows it, they can press the "back" key, and the keypad is removed, revealing the results field. But I want the keypad to disappear when the user touches the "execute" button in the app without pressing the "back" key.
I have been researching this, and some suggested using finish(); But this doesn't only remove the keypad, it also exits the whole program.
So what's the easiest way to only remove the keypad, leaving the underlying TextView displayed? I want to include this in the onClick view that executes the math.
Any suggestions are appreciated.
Just add this code in the onClick method:
InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(yourSubmiBtn.getWindowToken(), 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With