鍵盤事件偵測:
- 所屬類別:View
- 介面interface:View.OnKeyListener
- public abstract boolean onKey (View v, int keyCode, KeyEvent event)
- Parameters
- v The view the key has been dispatched to.
- keyCode The code for the physical key that was pressed
- event The KeyEvent object containing full information about the event.
- Returns
- True if the listener has consumed the event, false otherwise.
- 範例
- 建立EditText的Listener
- editText.setOnKeyListener(new OnKeyListener()
- 偵測Key事件
- public boolean onKey(View v, int keyCode, KeyEvent event)
- 取出Key事件
- if (keyCode == KeyEvent.KEYCODE_ENTER)
- 範例下載
沒有留言:
張貼留言