DecimalDigitsInputFilter

class DecimalDigitsInputFilter @JvmOverloads constructor(decimalDigits: Int) : InputFilter

小数位数筛选器,支持大于0的自然数,默认2位小数.

注意: setInputType(InputType.TYPE_CLASS_NUMBER)之后,只能输入数字; setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL)之后,只能输入数字,点; 需要支持负号的方案: setRawInputTYpe(InputType.TYPE_CLASS_NUMBER),并且调用[android.widget.TextView.setKeyListener]或者 digits限制可输入字符中加入负号、数字、点,支持负数和小数输入

Author

Ayvytr 's GitHub

Since

3.0.7

Constructors

DecimalDigitsInputFilter
Link copied to clipboard
@JvmOverloads
fun DecimalDigitsInputFilter(decimalDigits: Int = DEFAULT_DECIMAL_DIGITS)

Types

Companion
Link copied to clipboard
object Companion

Functions

filter
Link copied to clipboard
open override fun filter(source: CharSequence, start: Int, end: Int, dest: Spanned, dstart: Int, dend: Int): CharSequence?
setDecimalDigits
Link copied to clipboard
fun setDecimalDigits(decimalDigits: Int)