Skip to content

Most visited

Recently visited

navigation
Added in API level 1

TextKeyListener

public class TextKeyListener
extends BaseKeyListener implements SpanWatcher

java.lang.Object
   ↳ 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

enum TextKeyListener.Capitalize

 

Inherited constants

From class android.text.method.MetaKeyKeyListener

Public constructors

TextKeyListener(TextKeyListener.Capitalize cap, boolean autotext)

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

Public methods

static void clear(Editable e)

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.

int getInputType()
static TextKeyListener getInstance()

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

static TextKeyListener getInstance(boolean autotext, TextKeyListener.Capitalize cap)

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

boolean onKeyDown(View view, Editable content, int keyCode, KeyEvent event)

Handles presses of the meta keys.

boolean onKeyOther(View view, Editable content, KeyEvent event)

Base implementation handles ACTION_MULTIPLE KEYCODE_UNKNOWN by inserting the event's text into the content.

boolean onKeyUp(View view, Editable content, int keyCode, KeyEvent event)

Handles release of the meta keys.

void onSpanAdded(Spannable s, Object what, int start, int end)

This method is called to notify you that the specified object has been attached to the specified range of the text.

void onSpanChanged(Spannable s, Object what, int start, int end, int st, int en)

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.

void onSpanRemoved(Spannable s, Object what, int start, int end)

This method is called to notify you that the specified object has been detached from the specified range of the text.

void release()
static boolean shouldCap(TextKeyListener.Capitalize cap, CharSequence cs, int off)

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

Inherited methods

From class android.text.method.BaseKeyListener
From class android.text.method.MetaKeyKeyListener
From class java.lang.Object
From interface android.text.method.KeyListener
From interface android.text.SpanWatcher

Public constructors

TextKeyListener

Added in API level 1
TextKeyListener (TextKeyListener.Capitalize cap, 
                boolean autotext)

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
void clear (Editable e)

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
int getInputType ()

Returns
int

getInstance

Added in API level 1
TextKeyListener getInstance ()

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

Returns
TextKeyListener

getInstance

Added in API level 1
TextKeyListener getInstance (boolean autotext, 
                TextKeyListener.Capitalize cap)

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.
Returns
TextKeyListener

onKeyDown

Added in API level 1
boolean onKeyDown (View view, 
                Editable content, 
                int keyCode, 
                KeyEvent event)

Handles presses of the meta keys.

Parameters
view View
content Editable
keyCode int
event KeyEvent
Returns
boolean

onKeyOther

Added in API level 3
boolean onKeyOther (View view, 
                Editable content, 
                KeyEvent event)

Base implementation handles ACTION_MULTIPLE KEYCODE_UNKNOWN by inserting the event's text into the content.

Parameters
view View
content Editable
event KeyEvent
Returns
boolean

onKeyUp

Added in API level 1
boolean onKeyUp (View view, 
                Editable content, 
                int keyCode, 
                KeyEvent event)

Handles release of the meta keys.

Parameters
view View
content Editable
keyCode int
event KeyEvent
Returns
boolean

onSpanAdded

Added in API level 1
void onSpanAdded (Spannable s, 
                Object what, 
                int start, 
                int end)

This method is called to notify you that the specified object has been attached to the specified range of the text.

Parameters
s Spannable
what Object
start int
end int

onSpanChanged

Added in API level 1
void onSpanChanged (Spannable s, 
                Object what, 
                int start, 
                int end, 
                int st, 
                int en)

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.

Parameters
s Spannable
what Object
start int
end int
st int
en int

onSpanRemoved

Added in API level 1
void onSpanRemoved (Spannable s, 
                Object what, 
                int start, 
                int end)

This method is called to notify you that the specified object has been detached from the specified range of the text.

Parameters
s Spannable
what Object
start int
end int

release

Added in API level 1
void release ()

shouldCap

Added in API level 1
boolean shouldCap (TextKeyListener.Capitalize cap, 
                CharSequence cs, 
                int off)

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.
Returns
boolean whether the character being inserted should be capitalized.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.