Question: How can you dynamically close the virtual keypad through code?
All I want to do is close it when the user clicks an "Ok" button because it is not closing itself even though the button now has focus.

Answer: 
[Close/hide the Android Soft Keyboard](https://stackoverflow.com/questions/1109022/how-to-close-hide-the-android-soft-keyboard)
Hi i got one more solution to hide keyboard by :

```
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

```

Here pass HIDE\_IMPLICIT\_ONLY at the position of showFlag and 0 at the position of hiddenFlag.
It will forcefully close soft Keyboard.