remove view keypad

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.


只需在onClick方法中添加以下代码即可:

InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(yourSubmiBtn.getWindowToken(), 0);
链接地址: http://www.djcxy.com/p/16612.html

上一篇: 如何在android应用程序中禁用android键盘

下一篇: 删除视图键盘