Skip to content

Most visited

Recently visited

navigation

Editable

public interface Editable
implements CharSequence, GetChars, Spannable, Appendable

android.text.Editable
Known Indirect Subclasses


This is the interface for text whose content and markup can be changed (as opposed to immutable text like Strings). If you make a DynamicLayout of an Editable, the layout will be reflowed as the text is changed.

Summary

Nested classes

class Editable.Factory

Factory used by TextView to create new Editables

Inherited constants

From interface android.text.Spanned

Public methods

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 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 methods

From interface java.lang.CharSequence
From interface android.text.GetChars
From interface android.text.Spannable
From interface java.lang.Appendable
From interface android.text.Spanned

Public methods

append

added in API level 1
Editable append (char text)

Convenience for append(String.valueOf(text)).

Parameters
text char: The character to append

Returns
Editable A reference to this Appendable

append

added in API level 1
Editable append (CharSequence text, 
                int start, 
                int end)

Convenience for replace(length(), length(), text, start, end)

Parameters
text CharSequence: The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".

start int: The index of the first character in the subsequence

end int: The index of the character following the last character in the subsequence

Returns
Editable A reference to this Appendable

append

added in API level 1
Editable append (CharSequence text)

Convenience for replace(length(), length(), text, 0, text.length())

Parameters
text CharSequence: The character sequence to append. If csq is null, then the four characters "null" are appended to this Appendable.

Returns
Editable A reference to this Appendable

clear

added in API level 1
void clear ()

Convenience for replace(0, length(), "", 0, 0). Note that this clears the text, not the spans; use clearSpans() if you need that.

clearSpans

added in API level 1
void clearSpans ()

Removes all spans from the Editable, as if by calling removeSpan(Object) on each of them.

delete

added in API level 1
Editable delete (int st, 
                int en)

Convenience for replace(st, en, "", 0, 0)

Parameters
st int

en int

Returns
Editable

getFilters

added in API level 1
InputFilter[] getFilters ()

Returns the array of input filters that are currently applied to changes to this Editable.

Returns
InputFilter[]

insert

added in API level 1
Editable insert (int where, 
                CharSequence text)

Convenience for replace(where, where, text, 0, text.length());

Parameters
where int

text CharSequence

Returns
Editable

insert

added in API level 1
Editable insert (int where, 
                CharSequence text, 
                int start, 
                int end)

Convenience for replace(where, where, text, start, end)

Parameters
where int

text CharSequence

start int

end int

Returns
Editable

replace

added in API level 1
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. If the source contains a span with SPAN_PARAGRAPH flag, and it does not satisfy the paragraph boundary constraint, it is not retained. As a special case, the cursor position is preserved even when the entire range where it is located is replaced.

Parameters
st int

en int

source CharSequence

start int

end int

Returns
Editable a reference to this object.

See also:

replace

added in API level 1
Editable replace (int st, 
                int en, 
                CharSequence text)

Convenience for replace(st, en, text, 0, text.length())

Parameters
st int

en int

text CharSequence

Returns
Editable

setFilters

added in API level 1
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 InputFilter

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)