本文介绍了Android-在自定义EditText上捕获退格键(删除)按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在EditText
定制上的软键盘中捕获退格/删除按钮事件.
I want to catch the backspace/delete button event in soft keyboard on EditText
custom.
我该怎么办?
我尝试了这些解决方案,但它们对我不起作用:
I tried these solutions but they do not work for me :
感谢您的帮助!
我使用函数DispatchKeyEvent找到了解决该问题的方法:
EDIT :I found a fix for that isssue with the function DispatchKeyEvent :
@Override public boolean dispatchKeyEvent(@NonNull KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN
&& event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
// ...
}
return super.dispatchKeyEvent(event);
}
推荐答案
我使用函数DispatchKeyEvent找到了针对该问题的修复程序:
I found a fix for that isssue with the function DispatchKeyEvent :
@Override public boolean dispatchKeyEvent(@NonNull KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN
&& event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
// ...
}
return super.dispatchKeyEvent(event);
}
这篇关于Android-在自定义EditText上捕获退格键(删除)按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!