Anroid: disapper soft keyboard when click on button

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:

  1. Add a ClickListener for search button
  2. In ClickListener implementation get InputMethodManager
  3. Call hideSoftInputFromWindow method from Input Manager with parameters
  4. Soft QWERTY Keyboard will be disappear
  5. That’s all [Code below]


InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(_searchEdtTxt.getWindowToken(), 0);





About M Moniruzzaman
A passionate software engineer, have been developing applications on various platforms such as Android, iPhone, .Net (C#) technologies and web based ASP.NET, PHP, JavaScript, jQuery technologies for more than 10 years. Especially I have expertise on developing applications for Android and iPhone, as well as service oriented, client-server based applications where clients will be reside on Android/iPhone that communicate with WCF(.NET) service hosted on server. I have completed certification in Microsoft Certified Professional Developer (MCPD) on .Net 4 . I have completed my graduation in -- B.Sc. (Engineering) in Computer Science and Engineering, ShahJalal University of Science and Technology, Bangladesh. Thanks, M. Moniruzzaman (Zaman)

One Response to Anroid: disapper soft keyboard when click on button

  1. Ronalddob says:

    My name is Ronald. Am new here. Am getting a lot of help from this forum.

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: