简体   繁体   中英

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

yes:

btn.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
    InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    mgr.hideSoftInputFromWindow(editText.getWindowToken(), 0);
}
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM