android 软键盘打开时如何捕获按键事件?
我知道如何通过重写来捕获活动中的关键事件
public boolean onKeyDown(int keyCode, KeyEvent event)
问题是当软键盘打开时甚至不会调用此方法... 有什么办法可以赶上这个事件吗?
I know how to catch key events in my activity by overriding
public boolean onKeyDown(int keyCode, KeyEvent event)
The problem is when the soft keyboard is open this method is not even called...
any way to catch the event anyway?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,当我们谈论软键盘时,这意味着它不那么容易使用。顺便说一下,与软键盘相关的方法没有达到预期的结果。例如:
我发现的解决方法是使用 TextWatcher。将此代码用于您的应用程序
这些方法按顺序调用:beforeTextChanged、onTextChanged 和 afterTextChanged。您可以捕获文本更改的任何阶段。
祝你好运!
Yes, when we speak about soft keyboard it's means that no so easy to use it. By the way methods that relate to soft keyboard take no expected result. For example:
The workaround that I've found is using of TextWatcher. Use this code for your application
These methods are called sequentially: beforeTextChanged, onTextChanged and afterTextChanged. You can catch any phase of text changing.
Good luck!