Android:HTC Desire 上的软键盘控制
我想要一个带有“执行”或“完成”按钮的数字键盘,可以关闭并执行计算类。感谢来自 Commonware 的关于从哪里开始的提示,我在模拟器上完美地工作了。然后我把它加载到我的 HTC 愿望上进行测试,但它根本不起作用。我确信这一定是因为 HTC sense 有自己的 ime,但一定有办法让这个功能在 HTC 手机上运行吗?还有其他人设法解决这个问题吗?
I wanted a numeric keypad that had a go or done button that closed and executed a calculation class. Thanks to a tip from commonware on where to start I got this working beautifully on the emulator. Then I came to load it on to my HTC desire for testing and it doesn't work at all. I'm sure it must be because of HTC sense having it's own ime but there must surely be a way to make this work on HTC phones? Anyone else managed to get around this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我可以复制您在 HTC Incredible 上看到的内容。
并非所有软键盘都支持 IME 操作按钮。有些(例如 Graffiti 软“键盘”)可能根本没有按钮,更不用说 IME 操作按钮了。甚至兼容性定义文档也没有提到为附带的键盘需要这样的操作按钮设备。
因此,您不应依赖 IME 操作按钮。如果存在,用户就可以使用它。然而,无论你的目标是什么,总是有一些其他的方法来实现。
I can replicate what I think you are seeing on the HTC Incredible.
Not all soft keyboards will support the IME action button. Some, like the Graffiti soft "keyboard", may have no buttons at all, let alone an IME action button. Even the Compatibility Definition Document says nothing about requiring such an action button for the keyboards supplied with a device.
Hence, you should not rely on the IME action button. If it is there, users can use it. However, always have some other means of accomplishing whatever your goal is.
我正在使用 onEditorActionListener 检测是否按下了 DONE / GO / RETURN 按钮,但检查 IME 选项和 KeyEvents 以涵盖 HTC 键盘以及任何接受 IME 选项的键盘。
(此代码适用于 HTC Incredible 键盘以及任何具有 IME 选项的键盘)
I am detecting whether the DONE / GO / RETURN button has been pressed using an onEditorActionListener, but checking for IME options and KeyEvents to cover HTC keyboards as well as any keyboards that accept IME options.
(This code works for HTC Incredible keyboards as well any keyboard that has IME options)
我使用带有 inputType="number" 的 EditText 并通过修改 Asha 的解决方案解决了问题:
焦点被移除以停止显示数字键盘。需要 IMM 是因为即使在清除焦点后软键盘仍然存在。
I was using an EditText with inputType="number" and solved the problem by modifying Asha's solution:
The focus was removed in order to stop showing the number pad. The imm was required because a soft keyboard was still present even after clearing focus.