Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android hide keyboard after pressing button

anyone know if android is possible to hide the keyboard of a inputText after pressing a button?

in my application the keyboard is always present after a consultation which is uncomfortable for the user

like image 701
itaravika Avatar asked Dec 28 '22 18:12

itaravika


1 Answers

yes:

btn.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
    InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    mgr.hideSoftInputFromWindow(editText.getWindowToken(), 0);
}
});
like image 88
jkhouw1 Avatar answered Jan 20 '23 12:01

jkhouw1