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 ofKeyListener, 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 | |
|---|---|
TextKeyListener(cap: TextKeyListener.Capitalize!, autotext: Boolean)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 |
Return the type of text that this key listener is manipulating, as per |
| open static TextKeyListener! |
Returns a new or existing instance with no automatic capitalization or correction. |
| open static TextKeyListener! |
getInstance(autotext: Boolean, cap: TextKeyListener.Capitalize!)Returns a new or existing instance with the specified capitalization and correction properties. |
| open Boolean |
Handles presses of the meta keys. |
| open Boolean |
onKeyOther(view: View!, content: Editable!, event: KeyEvent!)Base implementation handles ACTION_MULTIPLE KEYCODE_UNKNOWN by inserting the event's text into the content. |
| open Boolean |
Handles release of the meta keys. |
| open Unit |
onSpanAdded(s: Spannable!, what: Any!, start: Int, end: Int)This method is called to notify you that the specified object has been attached to the specified range of the text. |
| open Unit |
This method is called to notify you that the specified object has been relocated from the range |
| open Unit |
onSpanRemoved(s: Spannable!, what: Any!, start: Int, end: Int)This method is called to notify you that the specified object has been detached from the specified range of the text. |
| open Unit |
release() |
| open static Boolean |
shouldCap(cap: TextKeyListener.Capitalize!, cs: CharSequence!, off: Int)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
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
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
open 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.
getInstance
open static fun getInstance(): TextKeyListener!
Returns a new or existing instance with no automatic capitalization or correction.
getInstance
open static fun getInstance(
autotext: Boolean,
cap: TextKeyListener.Capitalize!
): TextKeyListener!
Returns a new or existing instance with the specified capitalization and correction properties.
| Parameters | |
|---|---|
autotext |
Boolean: whether to automatically do spelling corrections. |
cap |
TextKeyListener.Capitalize!: when, if ever, to automatically capitalize. |
onKeyDown
open fun onKeyDown(
view: View!,
content: Editable!,
keyCode: Int,
event: KeyEvent!
): Boolean
Handles presses of the meta keys.
onKeyOther
open fun onKeyOther(
view: View!,
content: Editable!,
event: KeyEvent!
): Boolean
Base implementation handles ACTION_MULTIPLE KEYCODE_UNKNOWN by inserting the event's text into the content.
onKeyUp
open fun onKeyUp(
view: View!,
content: Editable!,
keyCode: Int,
event: KeyEvent!
): Boolean
Handles release of the meta keys.
onSpanAdded
open fun onSpanAdded(
s: Spannable!,
what: Any!,
start: Int,
end: Int
): Unit
This method is called to notify you that the specified object has been attached to the specified range of the text.
onSpanChanged
open fun onSpanChanged(
s: Spannable!,
what: Any!,
start: Int,
end: Int,
st: Int,
en: Int
): Unit
This method is called to notify you that the specified object has been relocated from the range ostart…oend to the new range nstart…nend of the text.
onSpanRemoved
open fun onSpanRemoved(
s: Spannable!,
what: Any!,
start: Int,
end: Int
): Unit
This method is called to notify you that the specified object has been detached from the specified range of the text.
shouldCap
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. |