Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在处理的应用程序中有几个 EditText 对象,并且需要学习如何在用户完成输入文本后关闭键盘,以便屏幕上被键盘阻止的按钮再次可见,并准备好执行操作.
在 Xcode 中,我使用 ResignFirstResponder 方法来执行此操作,例如,当用户单击键盘上的“完成”按钮时。我假设这在 Android 中也是可能的,但我不确定。我很感激任何帮助!
隐藏虚拟键盘的代码:
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
将它放在“完成”按钮的 onClick() 中,您将有理由相信 Android 与 Xcode 一样强大(如果不是更多的话)。