4

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.

Tawani
  • 10,649
  • 20
  • 77
  • 104
  • I'm sure if you goto ... I think it's Freenode IRC server, there's an android-dev channel that is EXTREMELY helpful. I'm sure if you go in there SOMEONE will know exactly how to do this (if it's possible) – Crowe T. Robot Dec 08 '09 at 19:17
  • @ Crowe: I went to freenode.net and I could not even figure out how it works. – Tawani Dec 08 '09 at 20:01
  • It's an IRC server, you need a IRC client. You could probably use Mibbit (it's a free web-based client). Freenode should be one of the servers it lets you join, and then you need to join the android-dev channel. – Chris Dec 08 '09 at 22:03

2 Answers2

3

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.

Saurabh Pareek
  • 6,876
  • 4
  • 26
  • 28
2

Close/hide the Android Soft Keyboard

Community
  • 1
  • 1
CommonsWare
  • 910,778
  • 176
  • 2,215
  • 2,253
  • That doesn't answer the question – Tawani Dec 08 '09 at 20:14
  • Yes, it does. "You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow, passing in the token of the window containing your edit field." That answers your question "How can you dynamically close the virtual keypad through code?". – CommonsWare Dec 09 '09 at 06:10
  • "hide" != "close" I will still need the keypad to open when I click again in another text field – Tawani Dec 09 '09 at 14:56
  • I had to attach this to a button so that the keypad can keep reappearing the next time I entered a text box – Tawani Jan 20 '10 at 15:01