简体   繁体   English

Android键盘解雇

[英]Android Keyboard Dismissal

I have several EditText objects in an app I'm working on, and need to learn how to dismiss the keyboard when the user is done entering text, so that buttons being blocked by the keyboard on the screen are visible again, and ready for action. 我正在处理的应用程序中有几个EditText对象,需要学习如何在用户输入文本时关闭键盘,以便屏幕上的键盘阻挡的按钮再次可见,并准备好执行操作。

In Xcode, I've used the ResignFirstResponder method to do this when, for example, the "Done" button is clicked on the keyboard by the user. 在Xcode中,我使用ResignFirstResponder方法来执行此操作,例如,用户在键盘上单击“完成”按钮。 I'm assuming this is possible in Android as well, but I'm not sure. 我认为这在Android中也是可行的,但我不确定。 I appreciate any help! 我感谢任何帮助!

Code to hide the Virtual Keyboard : 用于隐藏虚拟键盘的代码:

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

Put it inside the onClick() of your "Done" button and you will have reasons to believe that Android is as powerful as Xcode (if not more). 把它放在你的“完成”按钮onClick()中 ,你就有理由相信Android和Xcode一样强大(如果不是更多)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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