CharInputFilter, LengthFilter, UpperCaseFilterpublic abstract class InputFilter extends Object
filter(java.lang.CharSequence,ohos.agp.text.InputFilter.Range,java.lang.CharSequence,ohos.agp.text.InputFilter.Range) method.
Both plain text and RichText are supported.| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
InputFilter.Range |
Describes a text range where the index is greater than or equal to
inStart and less than inEnd,
as in other scenarios where text ranges are specified. |
| 构造器 | 说明 |
|---|---|
InputFilter() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
abstract CharSequence |
filter(CharSequence source,
InputFilter.Range sourceRange,
CharSequence dest,
InputFilter.Range destRange) |
Filters the input text, which can be plain text or
RichText. |
public abstract 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.source - 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.