Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用在电话设备上连接了键盘(硬件)的设备。现在我想在单击键盘上的确定按钮后获取事件。我发现我们使用 DPAD_CENTER 来指定 OK 按钮。任何人都可以帮助我解决这个问题。如何为此确定按钮设置侦听器。谢谢
覆盖 onkeydown 函数,您可以对按下的任何硬件键执行操作
public boolean onKeyDown(int keyCode, KeyEvent event){ if(keyCode==KeyEvent.KEYCODE_DPAD_CENTER){ // Do what you have to do here } return false; }