I have an EditText
and a Button
in my layout.
After writing in the edit field and clicking on the Button
, I want to hide the virtual keyboard. I assume that this is a simple piece of code, but where can I find an example of it?
I have an EditText
and a Button
in my layout.
After writing in the edit field and clicking on the Button
, I want to hide the virtual keyboard. I assume that this is a simple piece of code, but where can I find an example of it?
Simple and Easy to use method, just call hideKeyboardFrom(YourActivity.this); to hide keyboard
Alternatively to this all around solution, if you wanted to close the soft keyboard from anywhere without having a reference to the (EditText) field that was used to open the keyboard, but still wanted to do it if the field was focused, you could use this (from an Activity):
Above answers work for different scenario's but If you want to hide the keyboard inside a view and struggling to get the right context try this:
and to get the context fetch it from constructor:)
use this
Also useful for hiding the soft-keyboard is:
This can be used to suppress the soft-keyboard until the user actually touches the editText View.