Android的解雇键盘键盘、Android

2023-09-04 08:04:13 作者:情话说给左耳听

我如何关闭键盘时,按钮是pressed?

How do I disable the keyboard when a button is pressed?

推荐答案

您希望禁用或驳回的虚拟键盘?

You want to disable or dismiss a virtual Keyboard?

如果您只想关闭它,你可以用code以下线在按钮的点击事件

If you want to just dismiss it you can use the following lines of code in your button's on click Event

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);