Page Summary
-
Editableis an interface for mutable text, supporting content and markup changes, unlike immutable strings. -
It provides methods for appending, inserting, deleting, and replacing text, as well as managing spans (markup objects).
-
Editableuses InputFilters to control and potentially modify text insertions. -
SpannableStringBuilderis a key implementation ofEditable, enabling changes to both text content and markup. -
Inherited constants from
Spannedoffer options for controlling span behavior and interaction with text modifications.
| Known Indirect Subclasses |
This is the interface for text whose content and markup can be changed (as opposed to immutable text like Strings).
Nested Class Summary
| class | Editable.Factory | Factory used by TextView to create new Editables. | |
Inherited Constant Summary
Public Method Summary
| abstract Editable |
append(char text)
Convenience for append(String.valueOf(text)).
|
| abstract Editable |
append(CharSequence text, int start, int end)
Convenience for replace(length(), length(), text, start, end)
|
| abstract Editable |
append(CharSequence text)
Convenience for replace(length(), length(), text, 0, text.length())
|
| abstract void |
clear()
Convenience for replace(0, length(), "", 0, 0)
|
| abstract void |
clearSpans()
Removes all spans from the Editable, as if by calling
Spannable.removeSpan(Object) on each of them. |
| abstract Editable |
delete(int st, int en)
Convenience for replace(st, en, "", 0, 0)
|
| abstract InputFilter[] |
getFilters()
Returns the array of input filters that are currently applied
to changes to this Editable.
|
| abstract Editable |
insert(int where, CharSequence text)
Convenience for replace(where, where, text, 0, text.length());
|
| abstract Editable |
insert(int where, CharSequence text, int start, int end)
Convenience for replace(where, where, text, start, end)
|
| abstract Editable |
replace(int st, int en, CharSequence source, int start, int end)
Replaces the specified range (
st…en) of text in this
Editable with a copy of the slice start…end from
source. |
| abstract Editable |
replace(int st, int en, CharSequence text)
Convenience for replace(st, en, text, 0, text.length())
|
| abstract void |
setFilters(InputFilter[] filters)
Sets the series of filters that will be called in succession
whenever the text of this Editable is changed, each of which has
the opportunity to limit or transform the text that is being inserted.
|
Inherited Method Summary
Public Methods
public abstract Editable append (char text)
Convenience for append(String.valueOf(text)).
Parameters
| text |
|---|
public abstract Editable append (CharSequence text, int start, int end)
Convenience for replace(length(), length(), text, start, end)
Parameters
| text | |
|---|---|
| start | |
| end |
public abstract Editable append (CharSequence text)
Convenience for replace(length(), length(), text, 0, text.length())
Parameters
| text |
|---|
public abstract void clear ()
Convenience for replace(0, length(), "", 0, 0)
public abstract void clearSpans ()
Removes all spans from the Editable, as if by calling
Spannable.removeSpan(Object) on each of them.
public abstract Editable delete (int st, int en)
Convenience for replace(st, en, "", 0, 0)
Parameters
| st | |
|---|---|
| en |
public abstract InputFilter[] getFilters ()
Returns the array of input filters that are currently applied to changes to this Editable.
public abstract Editable insert (int where, CharSequence text)
Convenience for replace(where, where, text, 0, text.length());
Parameters
| where | |
|---|---|
| text |
public abstract Editable insert (int where, CharSequence text, int start, int end)
Convenience for replace(where, where, text, start, end)
Parameters
| where | |
|---|---|
| text | |
| start | |
| end |
public abstract Editable replace (int st, int en, CharSequence source, int start, int end)
Replaces the specified range (st…en) of text in this
Editable with a copy of the slice start…end from
source. The destination slice may be empty, in which case
the operation is an insertion, or the source slice may be empty,
in which case the operation is a deletion.
Before the change is committed, each filter that was set with
setFilters(InputFilter[]) is given the opportunity to modify the
source text.
If source
is Spanned, the spans from it are preserved into the Editable.
Existing spans within the Editable that entirely cover the replaced
range are retained, but any that were strictly within the range
that was replaced are removed. As a special case, the cursor
position is preserved even when the entire range where it is
located is replaced.
Parameters
| st | |
|---|---|
| en | |
| source | |
| start | |
| end |
Returns
- a reference to this object.
public abstract Editable replace (int st, int en, CharSequence text)
Convenience for replace(st, en, text, 0, text.length())
Parameters
| st | |
|---|---|
| en | |
| text |
public abstract void setFilters (InputFilter[] filters)
Sets the series of filters that will be called in succession whenever the text of this Editable is changed, each of which has the opportunity to limit or transform the text that is being inserted.
Parameters
| filters |
|---|