public abstract class NumberKeyListener extends BaseKeyListener implements InputFilter
KeyListener
, this class is only concerned
with hardware keyboards. Software input methods have no obligation to trigger
the methods in this class.InputFilter.AllCaps, InputFilter.LengthFilter
META_ALT_LOCKED, META_ALT_ON, META_CAP_LOCKED, META_SELECTING, META_SHIFT_ON, META_SYM_LOCKED, META_SYM_ON
Constructor and Description |
---|
NumberKeyListener() |
Modifier and Type | Method and Description |
---|---|
CharSequence |
filter(CharSequence source,
int start,
int end,
Spanned dest,
int dstart,
int dend)
This method is called when the buffer is going to replace the
range
dstart … dend of dest
with the new text from the range start … end
of source . |
protected abstract char[] |
getAcceptedChars()
You can say which characters you can accept.
|
protected int |
lookup(KeyEvent event,
Spannable content) |
protected static boolean |
ok(char[] accept,
char c) |
boolean |
onKeyDown(View view,
Editable content,
int keyCode,
KeyEvent event)
Handles presses of the meta keys.
|
backspace, forwardDelete, onKeyOther
adjustMetaAfterKeypress, adjustMetaAfterKeypress, clearMetaKeyState, clearMetaKeyState, clearMetaKeyState, getMetaState, getMetaState, getMetaState, getMetaState, handleKeyDown, handleKeyUp, isMetaTracker, isSelectingMetaTracker, onKeyUp, resetLockedMeta, resetLockedMeta, resetMetaState, startSelecting, stopSelecting
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clearMetaKeyState, getInputType, onKeyUp
protected abstract char[] getAcceptedChars()
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend)
InputFilter
dstart … dend
of dest
with the new text from the range start … end
of source
. Return the CharSequence that you would
like to have placed there instead, including an empty string
if appropriate, or null
to accept the original
replacement. Be careful to not to reject 0-length replacements,
as this is what happens when you delete text. Also beware that
you should not attempt to make any changes to dest
from this method; you may only examine it for context.
Note: If source is an instance of Spanned
or
Spannable
, the span objects in the source should be
copied into the filtered result (i.e. the non-null return value).
TextUtils.copySpansFrom(android.text.Spanned, int, int, java.lang.Class, android.text.Spannable, int)
can be used for convenience.filter
in interface InputFilter
protected static boolean ok(char[] accept, char c)
public boolean onKeyDown(View view, Editable content, int keyCode, KeyEvent event)
MetaKeyKeyListener
onKeyDown
in interface KeyListener
onKeyDown
in class BaseKeyListener