Anroid: disapper soft keyboard when click on button
October 14, 2010 1 Comment
If this is the use case that you write on text box and then when you click on button such as search button the soft QWERTY keyboard would be disappeared. Then, for example, there is one search EditText and one Search Button you may follow the following steps:
- Add a ClickListener for search button
- In ClickListener implementation get InputMethodManager
- Call hideSoftInputFromWindow method from Input Manager with parameters
- Soft QWERTY Keyboard will be disappear
- That’s all [Code below]
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(_searchEdtTxt.getWindowToken(), 0);
References:
1. anddev.com
My name is Ronald. Am new here. Am getting a lot of help from this forum.