有没有办法在我点击 android 中的按钮后隐藏虚拟键盘?键盘最初是在用户触摸编辑文本组件时弹出的;我希望它在按下按钮后关闭。
最佳答案
隐藏键盘的最佳实践:
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
它会自动接收当前焦点并隐藏键盘。有多少 EditText
View 并不重要。
关于android - 单击按钮时隐藏虚拟键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5360696/