I am getting an EditText along with a Button during my layout. After writing within the edit area and hitting the Button, I wish to hide the virtual keyboard. I suppose there must be an easy, one- or two-lining to attempt. How can i find a good example of it?

You are able to pressure Android to cover the virtual keyboard while using InputMethodManager, calling hideSoftInputFromWindow, passing within the token from the window that contains your edit area.

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)

imm.hideSoftInputFromWindow(myEditText.getWindowToken(), )

This can pressure the laptop keyboard to become hidden in most situations. In some instances you will need to pass in InputMethodManager.HIDE_IMPLICIT_ONLY because the second parameter to make sure you only hide the laptop keyboard once the user did not clearly pressure it to look (by holding lower menu).

Also helpful for hiding the soft keyboard is:


This can be to suppress the laptop keyboard before the user really touched the edittext view.

Meier's solution works best for me too. During my situation the very best degree of my Application is really a tabHost and I wish to hide the keyword when switching tabs - I recieve your window token in the tabHost View.

   tabHost.setOnTabChangedListener(new OnTabChangeListener()



Please do this below code in oncreate()

EditText edtView=(EditText)findViewById(R.id.editTextConvertValue)


Easiest way:

//Show soft-keyboard:


//hide keyboard :


You have to make use of the following code to cover the soft keyboard :

 InputMethodManager inputManager = (InputMethodManager)




For pressure show and hide we have to use http://android-codes-good examples.blogspot.com/2011/11/show-or-hide-soft-keyboard-on-opening.html

as proven about this blog

Suppose u have edit textbox with id edsearch

and button with id btnsearch

btnsearch.setOnClickListener(new View.OnClickListener() produced method stub

                imm.hideSoftInputFromWindow(edSearch.getWindowToken(), )


                edSearch.setText("")   )