# DigitsKeyListener

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Inherited Constants](https://developer.android.com/reference/android/text/method/DigitsKeyListener#inhconstants)\|[Ctors](https://developer.android.com/reference/android/text/method/DigitsKeyListener#pubctors)\|[Methods](https://developer.android.com/reference/android/text/method/DigitsKeyListener#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/text/method/DigitsKeyListener#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/text/method/DigitsKeyListener#inhmethods)  

# DigitsKeyListener

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/text/method/DigitsKeyListener "View this page in Kotlin")\|Java

`
public


class
DigitsKeyListener
`  
`


``


``


``

extends `[NumberKeyListener](https://developer.android.com/reference/android/text/method/NumberKeyListener)`


``


`

|---|---|---|---|---------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||||
| ↳ | [android.text.method.MetaKeyKeyListener](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener) ||||
|   | ↳ | [android.text.method.BaseKeyListener](https://developer.android.com/reference/android/text/method/BaseKeyListener) |||
|   |   | ↳ | [android.text.method.NumberKeyListener](https://developer.android.com/reference/android/text/method/NumberKeyListener) ||
|   |   |   | ↳ | android.text.method.DigitsKeyListener |

<br />

*** ** * ** ***

For digits-only text entry

<br />

As for all implementations of[KeyListener](https://developer.android.com/reference/android/text/method/KeyListener), this class is only concerned with hardware keyboards. Software input methods have no obligation to trigger the methods in this class.

<br />

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ### Inherited constants                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From class[android.text.method.MetaKeyKeyListener](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener) |-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `int` | [META_ALT_LOCKED](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#META_ALT_LOCKED) Flag that indicates that the ALT key is locked.                | | `int` | [META_ALT_ON](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#META_ALT_ON) Flag that indicates that the ALT key is on.                            | | `int` | [META_CAP_LOCKED](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#META_CAP_LOCKED) Flag that indicates that the SHIFT key is locked in CAPS mode. | | `int` | [META_SHIFT_ON](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#META_SHIFT_ON) Flag that indicates that the SHIFT key is on.                      | | `int` | [META_SYM_LOCKED](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#META_SYM_LOCKED) Flag that indicates that the SYM key is locked.                | | `int` | [META_SYM_ON](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#META_SYM_ON) Flag that indicates that the SYM key is on.                            | |

|                                                                                                                                                                                                    ### Public constructors                                                                                                                                                                                                     ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener#DigitsKeyListener())`() ` *This constructor is deprecated. Use[DigitsKeyListener(java.util.Locale)](https://developer.android.com/reference/android/text/method/DigitsKeyListener#DigitsKeyListener(java.util.Locale))instead.*                                                                                        |
| ` `[DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener#DigitsKeyListener(boolean,%20boolean))`(boolean sign, boolean decimal) ` *This constructor is deprecated. Use[DigitsKeyListener(java.util.Locale, boolean, boolean)](https://developer.android.com/reference/android/text/method/DigitsKeyListener#DigitsKeyListener(java.util.Locale,%20boolean,%20boolean))instead.* |
| ` `[DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener#DigitsKeyListener(java.util.Locale))`(`[Locale](https://developer.android.com/reference/java/util/Locale)` locale) `                                                                                                                                                                                                   |
| ` `[DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener#DigitsKeyListener(java.util.Locale,%20boolean,%20boolean))`(`[Locale](https://developer.android.com/reference/java/util/Locale)` locale, boolean sign, boolean decimal) `                                                                                                                                              |

|                                                                                                                                                                                                                                                                                                                            ### Public methods                                                                                                                                                                                                                                                                                                                            ||
|--------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)                            | ` `[filter](https://developer.android.com/reference/android/text/method/DigitsKeyListener#filter(java.lang.CharSequence,%20int,%20int,%20android.text.Spanned,%20int,%20int))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` source, int start, int end, `[Spanned](https://developer.android.com/reference/android/text/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`. |
| ` int`                                                                                                       | ` `[getInputType](https://developer.android.com/reference/android/text/method/DigitsKeyListener#getInputType())`() ` Returns the input type for the listener.                                                                                                                                                                                                                                                                                                                                                                                              |
| ` static `[DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener) | ` `[getInstance](https://developer.android.com/reference/android/text/method/DigitsKeyListener#getInstance(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` accepted) ` Returns a DigitsKeyListener that accepts only the characters that appear in the specified String.                                                                                                                                                                                                                                          |
| ` static `[DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener) | ` `[getInstance](https://developer.android.com/reference/android/text/method/DigitsKeyListener#getInstance())`() ` *This method was deprecated in API level 26. Use[getInstance(java.util.Locale)](https://developer.android.com/reference/android/text/method/DigitsKeyListener#getInstance(java.util.Locale))instead.*                                                                                                                                                                                                                                   |
| ` static `[DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener) | ` `[getInstance](https://developer.android.com/reference/android/text/method/DigitsKeyListener#getInstance(java.util.Locale))`(`[Locale](https://developer.android.com/reference/java/util/Locale)` locale) ` Returns a DigitsKeyListener that accepts the locale-appropriate digits.                                                                                                                                                                                                                                                                      |
| ` static `[DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener) | ` `[getInstance](https://developer.android.com/reference/android/text/method/DigitsKeyListener#getInstance(java.util.Locale,%20boolean,%20boolean))`(`[Locale](https://developer.android.com/reference/java/util/Locale)` locale, boolean sign, boolean decimal) ` Returns a DigitsKeyListener that accepts the locale-appropriate digits, plus the locale-appropriate plus or minus sign (only at the beginning) and/or the locale-appropriate decimal separator (only one per field) if specified.                                                       |
| ` static `[DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener) | ` `[getInstance](https://developer.android.com/reference/android/text/method/DigitsKeyListener#getInstance(boolean,%20boolean))`(boolean sign, boolean decimal) ` *This method was deprecated in API level 26. Use[getInstance(java.util.Locale, boolean, boolean)](https://developer.android.com/reference/android/text/method/DigitsKeyListener#getInstance(java.util.Locale,%20boolean,%20boolean))instead.*                                                                                                                                            |

|                                                                                ### Protected methods                                                                                 ||
|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` char[]` | ` `[getAcceptedChars](https://developer.android.com/reference/android/text/method/DigitsKeyListener#getAcceptedChars())`() ` You can say which characters you can accept. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[android.text.method.NumberKeyListener](https://developer.android.com/reference/android/text/method/NumberKeyListener)` ` |-----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[CharSequence](https://developer.android.com/reference/java/lang/CharSequence) | ` `[filter](https://developer.android.com/reference/android/text/method/NumberKeyListener#filter(java.lang.CharSequence,%20int,%20int,%20android.text.Spanned,%20int,%20int))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` source, int start, int end, `[Spanned](https://developer.android.com/reference/android/text/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`. | | ` abstract char[]`                                                                | ` `[getAcceptedChars](https://developer.android.com/reference/android/text/method/NumberKeyListener#getAcceptedChars())`() ` You can say which characters you can accept.                                                                                                                                                                                                                                                                                                                                                                                  | | ` int`                                                                            | ` `[lookup](https://developer.android.com/reference/android/text/method/NumberKeyListener#lookup(android.view.KeyEvent,%20android.text.Spannable))`(`[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event, `[Spannable](https://developer.android.com/reference/android/text/Spannable)` content) `                                                                                                                                                                                                                            | | ` static boolean`                                                                 | ` `[ok](https://developer.android.com/reference/android/text/method/NumberKeyListener#ok(char[],%20char))`(char[] accept, char c) `                                                                                                                                                                                                                                                                                                                                                                                                                        | | ` boolean`                                                                        | ` `[onKeyDown](https://developer.android.com/reference/android/text/method/NumberKeyListener#onKeyDown(android.view.View,%20android.text.Editable,%20int,%20android.view.KeyEvent))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[Editable](https://developer.android.com/reference/android/text/Editable)` content, int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Handles presses of the meta keys.                                                                    | ||
| From class` `[android.text.method.BaseKeyListener](https://developer.android.com/reference/android/text/method/BaseKeyListener)` ` |------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` boolean` | ` `[backspace](https://developer.android.com/reference/android/text/method/BaseKeyListener#backspace(android.view.View,%20android.text.Editable,%20int,%20android.view.KeyEvent))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[Editable](https://developer.android.com/reference/android/text/Editable)` content, int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Performs the action that happens when you press the[KeyEvent.KEYCODE_DEL](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_DEL)key in a[TextView](https://developer.android.com/reference/android/widget/TextView).                         | | ` boolean` | ` `[forwardDelete](https://developer.android.com/reference/android/text/method/BaseKeyListener#forwardDelete(android.view.View,%20android.text.Editable,%20int,%20android.view.KeyEvent))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[Editable](https://developer.android.com/reference/android/text/Editable)` content, int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Performs the action that happens when you press the[KeyEvent.KEYCODE_FORWARD_DEL](https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_FORWARD_DEL)key in a[TextView](https://developer.android.com/reference/android/widget/TextView). | | ` boolean` | ` `[onKeyDown](https://developer.android.com/reference/android/text/method/BaseKeyListener#onKeyDown(android.view.View,%20android.text.Editable,%20int,%20android.view.KeyEvent))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[Editable](https://developer.android.com/reference/android/text/Editable)` content, int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Handles presses of the meta keys.                                                                                                                                                                                                                                | | ` boolean` | ` `[onKeyOther](https://developer.android.com/reference/android/text/method/BaseKeyListener#onKeyOther(android.view.View,%20android.text.Editable,%20android.view.KeyEvent))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[Editable](https://developer.android.com/reference/android/text/Editable)` content, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Base implementation handles ACTION_MULTIPLE KEYCODE_UNKNOWN by inserting the event's text into the content.                                                                                                                                                                        | ||
| From class` `[android.text.method.MetaKeyKeyListener](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener)` ` |---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` static void`      | ` `[adjustMetaAfterKeypress](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#adjustMetaAfterKeypress(android.text.Spannable))`(`[Spannable](https://developer.android.com/reference/android/text/Spannable)` content) ` Call this method after you handle a keypress so that the meta state will be reset to unshifted (if it is not still down) or primed to be reset to unshifted (once it is released).                                                | | ` static long`      | ` `[adjustMetaAfterKeypress](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#adjustMetaAfterKeypress(long))`(long state) ` Call this method after you handle a keypress so that the meta state will be reset to unshifted (if it is not still down) or primed to be reset to unshifted (once it is released).                                                                                                                                             | | ` static void`      | ` `[clearMetaKeyState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#clearMetaKeyState(android.text.Editable,%20int))`(`[Editable](https://developer.android.com/reference/android/text/Editable)` content, int states) `                                                                                                                                                                                                                               | | ` long`             | ` `[clearMetaKeyState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#clearMetaKeyState(long,%20int))`(long state, int which) ` Clears the state of the specified meta key if it is locked.                                                                                                                                                                                                                                                              | | ` void`             | ` `[clearMetaKeyState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#clearMetaKeyState(android.view.View,%20android.text.Editable,%20int))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[Editable](https://developer.android.com/reference/android/text/Editable)` content, int states) `                                                                                                                                | | ` static final int` | ` `[getMetaState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#getMetaState(java.lang.CharSequence))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text) ` Gets the state of the meta keys.                                                                                                                                                                                                                        | | ` static final int` | ` `[getMetaState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#getMetaState(java.lang.CharSequence,%20int))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, int meta) ` Gets the state of a particular meta key.                                                                                                                                                                                               | | ` static final int` | ` `[getMetaState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#getMetaState(long))`(long state) ` Gets the state of the meta keys.                                                                                                                                                                                                                                                                                                                     | | ` static final int` | ` `[getMetaState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#getMetaState(java.lang.CharSequence,%20android.view.KeyEvent))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Gets the state of the meta keys for a specific key event.                                                                                   | | ` static final int` | ` `[getMetaState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#getMetaState(long,%20int))`(long state, int meta) ` Gets the state of a particular meta key.                                                                                                                                                                                                                                                                                            | | ` static final int` | ` `[getMetaState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#getMetaState(java.lang.CharSequence,%20int,%20android.view.KeyEvent))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, int meta, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Gets the state of a particular meta key to use with a particular key event.                                                | | ` static long`      | ` `[handleKeyDown](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#handleKeyDown(long,%20int,%20android.view.KeyEvent))`(long state, int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Handles presses of the meta keys.                                                                                                                                                                                  | | ` static long`      | ` `[handleKeyUp](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#handleKeyUp(long,%20int,%20android.view.KeyEvent))`(long state, int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Handles release of the meta keys.                                                                                                                                                                                      | | ` static boolean`   | ` `[isMetaTracker](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#isMetaTracker(java.lang.CharSequence,%20java.lang.Object))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, `[Object](https://developer.android.com/reference/java/lang/Object)` what) ` Returns true if this object is one that this class would use to keep track of any meta state in the specified text.                                    | | ` static boolean`   | ` `[isSelectingMetaTracker](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#isSelectingMetaTracker(java.lang.CharSequence,%20java.lang.Object))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` text, `[Object](https://developer.android.com/reference/java/lang/Object)` what) ` Returns true if this object is one that this class would use to keep track of the selecting meta state in the specified text.        | | ` boolean`          | ` `[onKeyDown](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#onKeyDown(android.view.View,%20android.text.Editable,%20int,%20android.view.KeyEvent))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[Editable](https://developer.android.com/reference/android/text/Editable)` content, int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Handles presses of the meta keys. | | ` boolean`          | ` `[onKeyUp](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#onKeyUp(android.view.View,%20android.text.Editable,%20int,%20android.view.KeyEvent))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[Editable](https://developer.android.com/reference/android/text/Editable)` content, int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` Handles release of the meta keys.     | | ` static long`      | ` `[resetLockedMeta](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#resetLockedMeta(long))`(long state) ` Call this if you are a method that ignores the locked meta state (arrow keys, for example) and you handle a key.                                                                                                                                                                                                                               | | ` static void`      | ` `[resetLockedMeta](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#resetLockedMeta(android.text.Spannable))`(`[Spannable](https://developer.android.com/reference/android/text/Spannable)` content) ` Call this if you are a method that ignores the locked meta state (arrow keys, for example) and you handle a key.                                                                                                                                  | | ` static void`      | ` `[resetMetaState](https://developer.android.com/reference/android/text/method/MetaKeyKeyListener#resetMetaState(android.text.Spannable))`(`[Spannable](https://developer.android.com/reference/android/text/Spannable)` text) ` Resets all meta state to inactive.                                                                                                                                                                                                                     | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||
| From interface` `[android.text.InputFilter](https://developer.android.com/reference/android/text/InputFilter)` ` |--------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[CharSequence](https://developer.android.com/reference/java/lang/CharSequence) | ` `[filter](https://developer.android.com/reference/android/text/InputFilter#filter(java.lang.CharSequence,%20int,%20int,%20android.text.Spanned,%20int,%20int))`(`[CharSequence](https://developer.android.com/reference/java/lang/CharSequence)` source, int start, int end, `[Spanned](https://developer.android.com/reference/android/text/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`. | ||
| From interface` `[android.text.method.KeyListener](https://developer.android.com/reference/android/text/method/KeyListener)` ` |---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void`    | ` `[clearMetaKeyState](https://developer.android.com/reference/android/text/method/KeyListener#clearMetaKeyState(android.view.View,%20android.text.Editable,%20int))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[Editable](https://developer.android.com/reference/android/text/Editable)` content, int states) ` Remove the given shift states from the edited text.                                                                                                                                                                                        | | ` abstract int`     | ` `[getInputType](https://developer.android.com/reference/android/text/method/KeyListener#getInputType())`() ` Return the type of text that this key listener is manipulating, as per[InputType](https://developer.android.com/reference/android/text/InputType).                                                                                                                                                                                                                                                                                                                             | | ` abstract boolean` | ` `[onKeyDown](https://developer.android.com/reference/android/text/method/KeyListener#onKeyDown(android.view.View,%20android.text.Editable,%20int,%20android.view.KeyEvent))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[Editable](https://developer.android.com/reference/android/text/Editable)` text, int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` If the key listener wants to handle this key, return true, otherwise return false and the caller (i.e. the widget host) will handle the key.     | | ` abstract boolean` | ` `[onKeyOther](https://developer.android.com/reference/android/text/method/KeyListener#onKeyOther(android.view.View,%20android.text.Editable,%20android.view.KeyEvent))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[Editable](https://developer.android.com/reference/android/text/Editable)` text, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` If the key listener wants to other kinds of key events, return true, otherwise return false and the caller (i.e. the widget host) will handle the key.             | | ` abstract boolean` | ` `[onKeyUp](https://developer.android.com/reference/android/text/method/KeyListener#onKeyUp(android.view.View,%20android.text.Editable,%20int,%20android.view.KeyEvent))`(`[View](https://developer.android.com/reference/android/view/View)` view, `[Editable](https://developer.android.com/reference/android/text/Editable)` text, int keyCode, `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent)` event) ` If the key listener wants to handle this key release, return true, otherwise return false and the caller (i.e. the widget host) will handle the key. | ||

## Public constructors

### DigitsKeyListener

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DigitsKeyListener ()
```

<br />

**This constructor is deprecated.**   
Use[DigitsKeyListener(java.util.Locale)](https://developer.android.com/reference/android/text/method/DigitsKeyListener#DigitsKeyListener(java.util.Locale))instead.

Allocates a DigitsKeyListener that accepts the ASCII digits 0 through 9.

<br />

### DigitsKeyListener

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DigitsKeyListener (boolean sign, 
                boolean decimal)
```

<br />

**This constructor is deprecated.**   
Use[DigitsKeyListener(java.util.Locale, boolean, boolean)](https://developer.android.com/reference/android/text/method/DigitsKeyListener#DigitsKeyListener(java.util.Locale,%20boolean,%20boolean))instead.

Allocates a DigitsKeyListener that accepts the ASCII digits 0 through 9, plus the ASCII plus or minus sign (only at the beginning) and/or the ASCII period ('.') as the decimal point (only one per field) if specified.

<br />

|         Parameters          ||
|-----------|------------------|
| `sign`    | `boolean` <br /> |
| `decimal` | `boolean` <br /> |

### DigitsKeyListener

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DigitsKeyListener (Locale locale)
```

<br />

<br />

|                     Parameters                      ||
|----------|-------------------------------------------|
| `locale` | `Locale`: This value may be`null`. <br /> |

### DigitsKeyListener

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DigitsKeyListener (Locale locale, 
                boolean sign, 
                boolean decimal)
```

<br />

<br />

|                      Parameters                      ||
|-----------|-------------------------------------------|
| `locale`  | `Locale`: This value may be`null`. <br /> |
| `sign`    | `boolean` <br />                          |
| `decimal` | `boolean` <br />                          |

## Public methods

### filter

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public 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`. 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<var translate="no">source</var>is an instance of[Spanned](https://developer.android.com/reference/android/text/Spanned)or[Spannable](https://developer.android.com/reference/android/text/Spannable), the span objects in the<var translate="no">source</var>should be copied into the filtered result (i.e. the non-null return value).[TextUtils.copySpansFrom](https://developer.android.com/reference/android/text/TextUtils#copySpansFrom(android.text.Spanned,%20int,%20int,%20java.lang.Class,%20android.text.Spannable,%20int))can be used for convenience if the span boundary indices would be remaining identical relative to the source.

<br />

|           Parameters            ||
|----------|-----------------------|
| `source` | `CharSequence` <br /> |
| `start`  | `int` <br />          |
| `end`    | `int` <br />          |
| `dest`   | `Spanned` <br />      |
| `dstart` | `int` <br />          |
| `dend`   | `int` <br />          |

|                                        Returns                                         ||
|--------------------------------------------------------------------------------|--------|
| [CharSequence](https://developer.android.com/reference/java/lang/CharSequence) | <br /> |

### getInputType

Added in[API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int getInputType ()
```

Returns the input type for the listener.

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

### getInstance

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static DigitsKeyListener getInstance (String accepted)
```

Returns a DigitsKeyListener that accepts only the characters that appear in the specified String. Note that not all characters may be available on every keyboard.

<br />

|                        Parameters                        ||
|------------|----------------------------------------------|
| `accepted` | `String`: This value cannot be`null`. <br /> |

|                                                                Returns                                                                 ||
|----------------------------------------------------------------------------------------------------|------------------------------------|
| [DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener) | This value cannot be`null`. <br /> |

### getInstance

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static DigitsKeyListener getInstance ()
```

<br />

**This method was deprecated in API level 26.**   
Use[getInstance(java.util.Locale)](https://developer.android.com/reference/android/text/method/DigitsKeyListener#getInstance(java.util.Locale))instead.

Returns a DigitsKeyListener that accepts the ASCII digits 0 through 9.

<br />

|                                                                Returns                                                                 ||
|----------------------------------------------------------------------------------------------------|------------------------------------|
| [DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener) | This value cannot be`null`. <br /> |

### getInstance

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static DigitsKeyListener getInstance (Locale locale)
```

Returns a DigitsKeyListener that accepts the locale-appropriate digits.

<br />

|                     Parameters                      ||
|----------|-------------------------------------------|
| `locale` | `Locale`: This value may be`null`. <br /> |

|                                                                Returns                                                                 ||
|----------------------------------------------------------------------------------------------------|------------------------------------|
| [DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener) | This value cannot be`null`. <br /> |

### getInstance

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static DigitsKeyListener getInstance (Locale locale, 
                boolean sign, 
                boolean decimal)
```

Returns a DigitsKeyListener that accepts the locale-appropriate digits, plus the locale-appropriate plus or minus sign (only at the beginning) and/or the locale-appropriate decimal separator (only one per field) if specified.

<br />

|                      Parameters                      ||
|-----------|-------------------------------------------|
| `locale`  | `Locale`: This value may be`null`. <br /> |
| `sign`    | `boolean` <br />                          |
| `decimal` | `boolean` <br />                          |

|                                                                Returns                                                                 ||
|----------------------------------------------------------------------------------------------------|------------------------------------|
| [DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener) | This value cannot be`null`. <br /> |

### getInstance

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static DigitsKeyListener getInstance (boolean sign, 
                boolean decimal)
```

<br />

**This method was deprecated in API level 26.**   
Use[getInstance(java.util.Locale, boolean, boolean)](https://developer.android.com/reference/android/text/method/DigitsKeyListener#getInstance(java.util.Locale,%20boolean,%20boolean))instead.

Returns a DigitsKeyListener that accepts the ASCII digits 0 through 9, plus the ASCII plus or minus sign (only at the beginning) and/or the ASCII period ('.') as the decimal point (only one per field) if specified.

<br />

|         Parameters          ||
|-----------|------------------|
| `sign`    | `boolean` <br /> |
| `decimal` | `boolean` <br /> |

|                                                                Returns                                                                 ||
|----------------------------------------------------------------------------------------------------|------------------------------------|
| [DigitsKeyListener](https://developer.android.com/reference/android/text/method/DigitsKeyListener) | This value cannot be`null`. <br /> |

## Protected methods

### getAcceptedChars

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected char[] getAcceptedChars ()
```

You can say which characters you can accept.

<br />

|                   Returns                    ||
|----------|------------------------------------|
| `char[]` | This value cannot be`null`. <br /> |