如何在 Activity 上实现 TextWatcher
在像 EditText
这样的可编辑对象上实现 TextWatcher
非常简单。但是,我想在没有特定可编辑焦点的情况下监听按键输入,以便用户可以启动 activity
,而无需单击 EditText
或任何内容。因此,您可以开始键入(硬键盘)或按住菜单软键直到软键盘出现,然后我想注册这些按键事件。
我尝试让我的 Activity
实现 TextWatcher
,但是像 onTextChanged()
这样的回调永远不会被调用。以前有人这样做过吗?
Implementing a TextWatcher
on an Editable like EditText
is quite simple. However, I want to listen for key input without a specific Editable in focus so that the user can launch the activity
, without clicking on an EditText
or anything. So you can just start typing (hard keyboard) or hold the menu soft key until the soft keyboard comes up and then I want to register these key events.
I have tried having my Activity
implement TextWatcher
, however the callbacks like onTextChanged()
never get called. Has anyone ever done this before?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为此时您想切换到 Activity.onKeyDown() 及相关。
I think at that point you want to switch to Activity.onKeyDown() and related.