嗨我在Android键盘按.
(点)时试图收到此事件
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == '.') {
Log.d("dot pressed" "dot presed");
我哪里出错了?
答案 0 :(得分:2)
请试试这个
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_NUMPAD_DOT) {
Log.d("dot pressed" "dot presed");
}
return super.onKeyDown(keyCode, event);
}
答案 1 :(得分:-1)
您应该使用KeyEvent.KEYCODE_PERIOD