Added in API level 1

DigitsKeyListener


open class DigitsKeyListener : NumberKeyListener
kotlin.Any
   ↳ android.text.method.MetaKeyKeyListener
   ↳ android.text.method.BaseKeyListener
   ↳ android.text.method.NumberKeyListener
   ↳ android.text.method.DigitsKeyListener

For digits-only text entry

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

Inherited constants
Public constructors

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

DigitsKeyListener(sign: Boolean, decimal: Boolean)

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.

DigitsKeyListener(locale: Locale?, sign: Boolean, decimal: Boolean)

Public methods
open CharSequence!
filter(source: CharSequence!, start: Int, end: Int, dest: Spanned!, dstart: Int, dend: Int)

open Int

Returns the input type for the listener.

open static DigitsKeyListener

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

open static DigitsKeyListener
getInstance(sign: Boolean, decimal: Boolean)

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.

open static DigitsKeyListener
getInstance(locale: Locale?)

Returns a DigitsKeyListener that accepts the locale-appropriate digits.

open static DigitsKeyListener
getInstance(locale: Locale?, sign: Boolean, decimal: Boolean)

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.

open static DigitsKeyListener
getInstance(accepted: String)

Returns a DigitsKeyListener that accepts only the characters that appear in the specified String.

Protected methods
open CharArray

Inherited functions

Public constructors

DigitsKeyListener

Added in API level 1
DigitsKeyListener()

Deprecated: Use DigitsKeyListener(java.util.Locale) instead.

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

DigitsKeyListener

Added in API level 1
DigitsKeyListener(
    sign: Boolean,
    decimal: Boolean)

Deprecated: Use DigitsKeyListener(java.util.Locale,boolean,boolean) 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.

DigitsKeyListener

Added in API level 26
DigitsKeyListener(locale: Locale?)
Parameters
locale Locale?: This value may be null.

DigitsKeyListener

Added in API level 26
DigitsKeyListener(
    locale: Locale?,
    sign: Boolean,
    decimal: Boolean)
Parameters
locale Locale?: This value may be null.

Public methods

filter

Added in API level 1
open fun filter(
    source: CharSequence!,
    start: Int,
    end: Int,
    dest: Spanned!,
    dstart: Int,
    dend: Int
): CharSequence!

getInputType

Added in API level 3
open fun getInputType(): Int

Returns the input type for the listener.

getInstance

Added in API level 1
Deprecated in API level 26
open static fun getInstance(): DigitsKeyListener

Deprecated: Use getInstance(java.util.Locale) instead.

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

Return
DigitsKeyListener This value cannot be null.

getInstance

Added in API level 1
Deprecated in API level 26
open static fun getInstance(
    sign: Boolean,
    decimal: Boolean
): DigitsKeyListener

Deprecated: Use getInstance(java.util.Locale,boolean,boolean) 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.

Return
DigitsKeyListener This value cannot be null.

getInstance

Added in API level 26
open static fun getInstance(locale: Locale?): DigitsKeyListener

Returns a DigitsKeyListener that accepts the locale-appropriate digits.

Parameters
locale Locale?: This value may be null.
Return
DigitsKeyListener This value cannot be null.

getInstance

Added in API level 26
open static fun getInstance(
    locale: Locale?,
    sign: Boolean,
    decimal: Boolean
): DigitsKeyListener

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.

Parameters
locale Locale?: This value may be null.
Return
DigitsKeyListener This value cannot be null.

getInstance

Added in API level 1
open static fun getInstance(accepted: String): DigitsKeyListener

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.

Parameters
accepted String: This value cannot be null.
Return
DigitsKeyListener This value cannot be null.

Protected methods

getAcceptedChars

Added in API level 1
protected open fun getAcceptedChars(): CharArray
Return
CharArray This value cannot be null.