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 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 | |
|---|---|
|
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?) |
|
DigitsKeyListener(locale: Locale?, sign: Boolean, decimal: Boolean) |
|
| Public methods | |
|---|---|
| open CharSequence! |
This method is called when the buffer is going to replace the range |
| 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(accepted: String)Returns a DigitsKeyListener that accepts only the characters that appear in the specified String. |
| 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. |
| Protected methods | |
|---|---|
| open CharArray |
You can say which characters you can accept. |
| Inherited functions | |
|---|---|
Public constructors
DigitsKeyListener
DigitsKeyListener()
Deprecated: Use DigitsKeyListener(java.util.Locale) instead.
Allocates a DigitsKeyListener that accepts the ASCII digits 0 through 9.
DigitsKeyListener
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
DigitsKeyListener(locale: Locale?)
| Parameters | |
|---|---|
locale |
Locale?: This value may be null. |
DigitsKeyListener
DigitsKeyListener(
locale: Locale?,
sign: Boolean,
decimal: Boolean)
| Parameters | |
|---|---|
locale |
Locale?: This value may be null. |
Public methods
filter
open fun filter(
source: CharSequence!,
start: Int,
end: Int,
dest: Spanned!,
dstart: Int,
dend: Int
): CharSequence!
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 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 can be used for convenience if the span boundary indices would be remaining identical relative to the source.
getInputType
open fun getInputType(): Int
Returns the input type for the listener.
getInstance
open static fungetInstance(): 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
open static fungetInstance(
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
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. |
getInstance
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
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. |
Protected methods
getAcceptedChars
protected open fun getAcceptedChars(): CharArray
You can say which characters you can accept.
| Return | |
|---|---|
CharArray |
This value cannot be null. |