检测BackSpace单击Android软键盘中的Key_down事件

发布于 2025-01-21 20:21:56 字数 599 浏览 3 评论 0原文

我已经搜索了接近6个月的搜索,但我无法获得有关如何在EditText视图中单击反戳的正确代码。

使用 setOnKeyListener 并执行if(event.getAction()== keyevent.action_down_down& keycode == keyevent.keycode.keycode_del)对API 14和API 14不起作用上面,我们无法再回复它。

另外,我得到了一个答案,该答案似乎从在这里,但它仅适用于inputtype.type_null丰富的文本编辑器。我从中得到的所有其他答案都不可靠。

再次使用 textwatcher 不会给我我想要的东西,因为我想在某些情况下返回true,因此使backspace不删除字符。

我认为可以检测到较高版本的Android中的Android软键盘中的Backspace,因为我在Facebook应用程序中看到了它。此

关于我如何完成此操作的任何想法吗?

I have searched for close to 6 months and I can't get a proper code on how to detect a backspace click in an EditText view.

Using the setOnKeyListener and doing if(event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_DEL) doesn't work for API 14 and above so we can no longer reply on it.

Also I got an answer which seems to work from here but it only works for InputType.TYPE_NULL and I need it to be a rich text editor. And all other answers I got from SO are not reliable.

And again using TextWatcher won't give me what I want, because I'll want to return true in some conditions therefore making the backspace not to delete the character.

I think it's possible to detect backspace click in Android soft keyboard in higher versions of Android, because I see it in the Facebook app. This Link is a 4sec video of how it looks on Facebook, and that's the exact same result I want.

Any idea on how I can get this done?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文