public final class LengthFilter extends InputFilter
RichText by length.
This can be used to limit the length of the input text within the specified editing area.
InputFilter.Range| 构造器 | 说明 |
|---|---|
LengthFilter(int inMax) |
Creates an instance of a string length filter.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
CharSequence |
filter(CharSequence source,
InputFilter.Range sourceRange,
CharSequence dest,
InputFilter.Range destRange) |
Filters the input text, which can be plain text or
RichText. |
public LengthFilter(int inMax)
inMax - Indicates the maximum length of a string.public CharSequence filter(CharSequence source, InputFilter.Range sourceRange, CharSequence dest, InputFilter.Range destRange)
RichText.
If the source is rich text, the text itself will change. In other cases, the text will not change.
Depending on the derived class of InputFilter, determine whether to pass null to dest
and destRange.
For example, pass null if the derived class is CharInputFilter or UpperCaseFilter.
For LengthFilter, do not pass null to dest and destRange, because these two
parameters restrict the source text together with sourceRange.filter 在类中 InputFiltersource - Indicates that source strings to be filtered.sourceRange - Indicates the filtering range of the source text. Only text in this range is filtered.dest - Indicates the destination text.destRange - Indicates the filtering range of the destination text.null if the input source text is null or the
specified Range is invalid.