dialog.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) { if(keyEvent.getAction() == KeyEvent.ACTION_UP){//按鍵起來才執行事件 switch (i){ case KeyEvent.KEYCODE_F1: delete(); break; case KeyEvent.KEYCODE_F2: add(bt_add,positiveButton); break; case KeyEvent.KEYCODE_F3: edit(bt_add,positiveButton); break; case KeyEvent.KEYCODE_F4: dialog.dismiss(); break; } } return false; } });
10-23
4405