Android : Programmatically Hidding the SoftKeyPad after selecting a item from the Dropdown list

Just add this code to hide it:

If you place it under the click event of a button after entering the text in editText if you click on the button your keypad will be hidden.

InputMethodManager i = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
i.hideSoftInputFromWindow(EditText.getWindowToken(), 0);

 

Note: This will be very uselfull when you work with Dropdown list (use this code under OnItemClickListener()).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s