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 ofKeyListener
, this class is only concerned
with hardware keyboards. Software input methods have no obligation to trigger
the methods in this class.
Summary
Inherited constants |
---|
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 |
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 | |
---|---|
Public constructors
TextKeyListener
public 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
public 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.
Parameters | |
---|---|
e |
Editable : the buffer whose text and state are to be cleared. |
getInstance
public static TextKeyListener getInstance ()
Returns a new or existing instance with no automatic capitalization or correction.
Returns | |
---|---|
TextKeyListener |
getInstance
public static 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
public 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
public 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
public 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
public 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
public 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
public 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 |
shouldCap
public 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.
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. |