4

.嗨,当我在 android 键盘上按(点)时,我正在尝试获取事件

 public boolean onKey(View v, int keyCode, KeyEvent event) {

   if (keyCode == '.') {
        Log.d("dot pressed" "dot presed");

我哪里错了?

4

2 回答 2

3

请试试这个

 public boolean onKeyDown(int keyCode, KeyEvent event) {
    if(keyCode == KeyEvent.KEYCODE_NUMPAD_DOT) {
        Log.d("dot pressed" "dot presed");

    }
    return super.onKeyDown(keyCode, event);
}
于 2013-05-20T04:56:35.163 回答
-1

您应该使用 KeyEvent.KEYCODE_PERIOD

于 2019-01-15T04:53:39.540 回答