KeyListener
interface KeyListener
android.text.method.KeyListener |
Interface for converting text key events into edit operations on an Editable class. Note that for most cases this interface has been superceded by general soft input methods as defined by android.view.inputmethod.InputMethod
; it should only be used for cases where an application has its own on-screen keypad and also wants to process hard keyboard events to match it.
Summary
Public methods | |
---|---|
abstract Unit |
clearMetaKeyState(view: View!, content: Editable!, states: Int) Remove the given shift states from the edited text. |
abstract Int |
Return the type of text that this key listener is manipulating, as per |
abstract Boolean |
If the key listener wants to handle this key, return true, otherwise return false and the caller (i.e. the widget host) will handle the key. |
abstract Boolean |
onKeyOther(view: View!, text: Editable!, event: KeyEvent!) If the key listener wants to other kinds of key events, return true, otherwise return false and the caller (i.e. the widget host) will handle the key. |
abstract Boolean |
If the key listener wants to handle this key release, return true, otherwise return false and the caller (i.e. the widget host) will handle the key. |
Public methods
clearMetaKeyState
abstract fun clearMetaKeyState(
view: View!,
content: Editable!,
states: Int
): Unit
Remove the given shift states from the edited text.
getInputType
abstract fun getInputType(): Int
Return the type of text that this key listener is manipulating, as per android.text.InputType
. This is used to determine the mode of the soft keyboard that is shown for the editor.
If you return android.text.InputType#TYPE_NULL
then no soft keyboard will provided. In other words, you must be providing your own key pad for on-screen input and the key listener will be used to handle input from a hard keyboard.
If you return any other value, a soft input method will be created when the user puts focus in the editor, which will provide a keypad and also consume hard key events. This means that the key listener will generally not be used, instead the soft input method will take care of managing key input as per the content type returned here.
onKeyDown
abstract fun onKeyDown(
view: View!,
text: Editable!,
keyCode: Int,
event: KeyEvent!
): Boolean
If the key listener wants to handle this key, return true, otherwise return false and the caller (i.e. the widget host) will handle the key.
onKeyOther
abstract fun onKeyOther(
view: View!,
text: Editable!,
event: KeyEvent!
): Boolean
If the key listener wants to other kinds of key events, return true, otherwise return false and the caller (i.e. the widget host) will handle the key.
onKeyUp
abstract fun onKeyUp(
view: View!,
text: Editable!,
keyCode: Int,
event: KeyEvent!
): Boolean
If the key listener wants to handle this key release, return true, otherwise return false and the caller (i.e. the widget host) will handle the key.