Question

I have an AutoCompleteTextView control serviced by an 'OnClick' Listener. It extracts a list of items from a database and populates the array adapter attached to the control. When I enter sufficient text to isolate an entry in the adapter list (usually about 2 characters) and I select the identified item, the adapterview's 'OnItemClick' Listener is invoked and I am able to identify the selected item, set the text in the AutoCompleteTextView, and execute its performCompletion() method. When this routine completes, the virtual keyboard remains in place. When I 'Tab' away from the control I receive a NullPointerException!

Any suggestions appreciated ...

PS: this display is generated programmatically.

Was it helpful?

Solution

You can use the snippet below to hide the keyboard.

private static void hideSoftKeyboard (View view) {
      InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(view.getApplicationWindowToken(), 0);
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top