Added in API level 1

TextKeyListener


open class TextKeyListener : BaseKeyListener, SpanWatcher
kotlin.Any
   ↳ android.text.method.MetaKeyKeyListener
   ↳ android.text.method.BaseKeyListener
   ↳ android.text.method.TextKeyListener

This is the key listener for typing normal text. It delegates to other key listeners appropriate to the current keyboard and language.

As for all implementations of KeyListener, this class is only concerned with hardware keyboards. Software input methods have no obligation to trigger the methods in this class.

Summary

Nested classes

Inherited constants
Public constructors

Creates a new TextKeyListener with the specified capitalization and correction properties.

Public methods
open static Unit

Clear all the input state (autotext, autocap, multitap, undo) from the specified Editable, going beyond Editable.

open Int

open static TextKeyListener!

Returns a new or existing instance with no automatic capitalization or correction.

open static TextKeyListener!

Returns a new or existing instance with the specified capitalization and correction properties.

open Boolean
onKeyDown(view: View!, content: Editable!, keyCode: Int, event: KeyEvent!)

open Boolean
onKeyOther(view: View!, content: Editable!, event: KeyEvent!)

open Boolean
onKeyUp(view: View!, content: Editable!, keyCode: Int, event: KeyEvent!)

open Unit
onSpanAdded(s: Spannable!, what: Any!, start: Int, end: Int)

open Unit
onSpanChanged(s: Spannable!, what: Any!, start: Int, end: Int, st: Int, en: Int)

open Unit
onSpanRemoved(s: Spannable!, what: Any!, start: Int, end: Int)

open Unit

open static Boolean

Returns whether it makes sense to automatically capitalize at the specified position in the specified text, with the specified rules.

Inherited functions

Public constructors

TextKeyListener

Added in API level 1
TextKeyListener(
    cap: TextKeyListener.Capitalize!,
    autotext: Boolean)

Creates a new TextKeyListener with the specified capitalization and correction properties.

Parameters
cap TextKeyListener.Capitalize!: when, if ever, to automatically capitalize.
autotext Boolean: whether to automatically do spelling corrections.

Public methods

clear

Added in API level 1
open static fun clear(e: Editable!): Unit

Clear all the input state (autotext, autocap, multitap, undo) from the specified Editable, going beyond Editable.clear(), which just clears the text but not the input state.

Parameters
e Editable!: the buffer whose text and state are to be cleared.

getInputType

Added in API level 3
open fun getInputType(): Int

getInstance

Added in API level 1
open static fun getInstance(): TextKeyListener!

Returns a new or existing instance with no automatic capitalization or correction.

getInstance

Added in API level 1
open static fun getInstance(
    autotext: Boolean,
    cap: TextKeyListener.Capitalize!
): TextKeyListener!

Returns a new or existing instance with the specified capitalization and correction properties.

Parameters
cap TextKeyListener.Capitalize!: when, if ever, to automatically capitalize.
autotext Boolean: whether to automatically do spelling corrections.

onKeyDown

Added in API level 1
open fun onKeyDown(
    view: View!,
    content: Editable!,
    keyCode: Int,
    event: KeyEvent!
): Boolean

onKeyOther

Added in API level 3
open fun onKeyOther(
    view: View!,
    content: Editable!,
    event: KeyEvent!
): Boolean

onKeyUp

Added in API level 1
open fun onKeyUp(
    view: View!,
    content: Editable!,
    keyCode: Int,
    event: KeyEvent!
): Boolean

onSpanAdded

Added in API level 1
open fun onSpanAdded(
    s: Spannable!,
    what: Any!,
    start: Int,
    end: Int
): Unit

onSpanChanged

Added in API level 1
open fun onSpanChanged(
    s: Spannable!,
    what: Any!,
    start: Int,
    end: Int,
    st: Int,
    en: Int
): Unit

onSpanRemoved

Added in API level 1
open fun onSpanRemoved(
    s: Spannable!,
    what: Any!,
    start: Int,
    end: Int
): Unit

release

Added in API level 1
open fun release(): Unit

shouldCap

Added in API level 1
open static fun shouldCap(
    cap: TextKeyListener.Capitalize!,
    cs: CharSequence!,
    off: Int
): Boolean

Returns whether it makes sense to automatically capitalize at the specified position in the specified text, with the specified rules.

Parameters
cap TextKeyListener.Capitalize!: the capitalization rules to consider.
cs CharSequence!: the text in which an insertion is being made.
off Int: the offset into that text where the insertion is being made.
Return
Boolean whether the character being inserted should be capitalized.