gpt4 book ai didi

java - Android Studio 提交回车

转载 作者:行者123 更新时间:2023-11-30 02:03:33 24 4
gpt4 key购买 nike

我正在使用使用摩托罗拉 CS3000 条码扫描器的 Android Studio 创建适用于 Android 的应用程序。它处于HID模式(模拟键盘),每次扫描输入一系列键,并以回车结束。

我正在使用 onEditorActionListener 来触发事件,我想知道如何通过扫描器的回车来触发所述事件。

最佳答案

@Override
public boolean onEditorAction(TextView textView, int actionId, KeyEvent event) {

if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {

switch (event.getAction()) {

case KeyEvent.ACTION_DOWN:
// for some reason we can get tons of repeated down events in the debugger, maybe from keyboard auto-repeat?
return true;

case KeyEvent.ACTION_UP:

// *** put your event code here ***

return true;
}

}
}

关于java - Android Studio 提交回车,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31117249/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com