android.text
public
class
android.text.SpannableStringBuilder
This is the class for text whose content and markup can both be changed.
Summary
SPAN_EXCLUSIVE_EXCLUSIVE,
SPAN_EXCLUSIVE_INCLUSIVE,
SPAN_INCLUSIVE_EXCLUSIVE,
SPAN_INCLUSIVE_INCLUSIVE,
SPAN_MARK_MARK,
SPAN_MARK_POINT,
SPAN_PARAGRAPH,
SPAN_POINT_MARK,
SPAN_POINT_POINT,
SPAN_PRIORITY,
SPAN_PRIORITY_SHIFT,
SPAN_USER,
SPAN_USER_SHIFT
|
|
|
Value |
|
int |
SPAN_EXCLUSIVE_EXCLUSIVE |
Spans of type SPAN_EXCLUSIVE_EXCLUSIVE do not expand
to include text inserted at either their starting or ending point. |
33 |
0x00000021 |
int |
SPAN_EXCLUSIVE_INCLUSIVE |
Non-0-length spans of type SPAN_INCLUSIVE_EXCLUSIVE expand
to include text inserted at their ending point but not at their
starting point. |
34 |
0x00000022 |
int |
SPAN_INCLUSIVE_EXCLUSIVE |
Non-0-length spans of type SPAN_INCLUSIVE_EXCLUSIVE expand
to include text inserted at their starting point but not at their
ending point. |
17 |
0x00000011 |
int |
SPAN_INCLUSIVE_INCLUSIVE |
Spans of type SPAN_INCLUSIVE_INCLUSIVE expand
to include text inserted at either their starting or ending point. |
18 |
0x00000012 |
int |
SPAN_MARK_MARK |
0-length spans with type SPAN_MARK_MARK behave like text marks:
they remain at their original offset when text is inserted
at that offset. |
17 |
0x00000011 |
int |
SPAN_MARK_POINT |
SPAN_MARK_POINT is a synonym for SPAN_INCLUSIVE_INCLUSIVE. |
18 |
0x00000012 |
int |
SPAN_PARAGRAPH |
SPAN_PARAGRAPH behaves like SPAN_INCLUSIVE_EXCLUSIVE
(SPAN_MARK_MARK), except that if either end of the span is
at the end of the buffer, that end behaves like _POINT
instead (so SPAN_INCLUSIVE_INCLUSIVE if it starts in the
middle and ends at the end, or SPAN_EXCLUSIVE_INCLUSIVE
if it both starts and ends at the end). |
51 |
0x00000033 |
int |
SPAN_POINT_MARK |
SPAN_POINT_MARK is a synonym for SPAN_EXCLUSIVE_EXCLUSIVE. |
33 |
0x00000021 |
int |
SPAN_POINT_POINT |
0-length spans with type SPAN_POINT_POINT behave like cursors:
they are pushed forward by the length of the insertion when text
is inserted at their offset. |
34 |
0x00000022 |
int |
SPAN_PRIORITY |
The bits specified by the SPAN_PRIORITY bitmap determine the order
of change notifications -- higher numbers go first. |
16711680 |
0x00ff0000 |
int |
SPAN_PRIORITY_SHIFT |
The bits numbered just above SPAN_PRIORITY_SHIFT determine the order
of change notifications -- higher numbers go first. |
16 |
0x00000010 |
int |
SPAN_USER |
The bits specified by the SPAN_USER bitfield are available
for callers to use to store scalar data associated with their
span object. |
-16777216 |
0xff000000 |
int |
SPAN_USER_SHIFT |
The bits numbered SPAN_USER_SHIFT and above are available
for callers to use to store scalar data associated with their
span object. |
24 |
0x00000018 |
Public Constructors
Public Methods
|
|
|
|
|
SpannableStringBuilder |
append(char text) |
|
|
|
|
|
SpannableStringBuilder |
append(CharSequence text) |
|
|
|
|
|
SpannableStringBuilder |
append(CharSequence text, int start, int end) |
|
|
|
|
|
char |
charAt(int where) |
|
|
|
|
|
void |
clear() |
|
|
|
|
|
void |
clearSpans() |
|
|
|
|
|
SpannableStringBuilder |
delete(int start, int end) |
|
|
|
|
|
void |
drawText(Canvas c, int start, int end, float x, float y, Paint p) |
|
|
|
|
|
void |
getChars(int start, int end, char[] dest, int destoff) |
|
|
|
|
|
InputFilter[] |
getFilters() |
|
|
|
|
|
int |
getSpanEnd(Object what) |
|
|
|
|
|
int |
getSpanFlags(Object what) |
|
|
|
|
|
int |
getSpanStart(Object what) |
|
|
|
|
<T> |
T[] |
getSpans(int queryStart, int queryEnd, Class<T> kind) |
|
|
|
|
|
int |
getTextWidths(int start, int end, float[] widths, Paint p) |
|
|
|
|
|
SpannableStringBuilder |
insert(int where, CharSequence tb) |
|
|
|
|
|
SpannableStringBuilder |
insert(int where, CharSequence tb, int start, int end) |
|
|
|
|
|
int |
length() |
|
|
|
|
|
float |
measureText(int start, int end, Paint p) |
|
|
|
|
|
int |
nextSpanTransition(int start, int limit, Class kind) |
|
|
|
|
|
void |
removeSpan(Object what) |
|
|
|
|
|
SpannableStringBuilder |
replace(int start, int end, CharSequence tb) |
|
|
|
|
|
SpannableStringBuilder |
replace(int start, int end, CharSequence tb, int tbstart, int tbend) |
|
|
|
|
|
void |
setFilters(InputFilter[] filters) |
|
|
|
|
|
void |
setSpan(Object what, int start, int end, int flags) |
|
|
|
|
|
CharSequence |
subSequence(int start, int end) |
|
|
|
|
|
String |
toString() |
|
|
|
static |
|
SpannableStringBuilder |
valueOf(CharSequence source) |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
append,
append,
append,
clear,
clearSpans,
delete,
getFilters,
insert,
insert,
replace,
replace,
setFilters
|
|
|
|
|
Editable |
append(CharSequence text) |
|
|
|
|
|
Editable |
append(CharSequence text, int start, int end) |
|
|
|
|
|
Editable |
append(char text) |
|
|
|
|
|
void |
clear() |
|
|
|
|
|
void |
clearSpans() |
|
|
|
|
|
Editable |
delete(int st, int en) |
|
|
|
|
|
InputFilter[] |
getFilters() |
|
|
|
|
|
Editable |
insert(int where, CharSequence text) |
|
|
|
|
|
Editable |
insert(int where, CharSequence text, int start, int end) |
|
|
|
|
|
Editable |
replace(int st, int en, CharSequence text) |
|
|
|
|
|
Editable |
replace(int st, int en, CharSequence source, int start, int end) |
|
|
|
|
|
void |
setFilters(InputFilter[] filters) |
|
|
|
|
|
void |
getChars(int start, int end, char[] dest, int destoff) |
Details
Public Constructors
public
SpannableStringBuilder()
Create a new SpannableStringBuilder with empty contents
public
SpannableStringBuilder(CharSequence text)
Create a new SpannableStringBuilder containing a copy of the
specified text, including its spans if any.
public
SpannableStringBuilder(CharSequence text, int start, int end)
Create a new SpannableStringBuilder containing a copy of the
specified slice of the specified text, including its spans if any.
Public Methods
Convenience for append(String.valueOf(text)).
Convenience for replace(length(), length(), text, 0, text.length())
Convenience for replace(length(), length(), text, start, end)
public
char
charAt(int where)
Return the char at the specified offset within the buffer.
public
void
clear()
Convenience for replace(0, length(), "", 0, 0)
Convenience for replace(st, en, "", 0, 0)
public
void
drawText(Canvas c, int start, int end, float x, float y, Paint p)
public
void
getChars(int start, int end, char[] dest, int destoff)
Copy the specified range of chars from this buffer into the
specified array, beginning at the specified offset.
Returns the array of input filters that are currently applied
to changes to this Editable.
public
int
getSpanEnd(Object what)
Return the buffer offset of the end of the specified
markup object, or -1 if it is not attached to this buffer.
public
int
getSpanFlags(Object what)
Return the flags of the end of the specified
markup object, or 0 if it is not attached to this buffer.
public
int
getSpanStart(Object what)
Return the buffer offset of the beginning of the specified
markup object, or -1 if it is not attached to this buffer.
public
T[]
getSpans(int queryStart, int queryEnd, Class<T> kind)
Return an array of the spans of the specified type that overlap
the specified range of the buffer. The kind may be Object.class to get
a list of all the spans regardless of type.
public
int
getTextWidths(int start, int end, float[] widths, Paint p)
Convenience for replace(where, where, text, 0, text.length());
Convenience for replace(where, where, text, start, end)
public
int
length()
Return the number of chars in the buffer.
public
float
measureText(int start, int end, Paint p)
public
int
nextSpanTransition(int start, int limit, Class kind)
Return the next offset after start
but less than or
equal to limit
where a span of the specified type
begins or ends.
public
void
removeSpan(Object what)
Remove the specified markup object from the buffer.
Convenience for replace(st, en, text, 0, text.length())
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.
public
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.
public
void
setSpan(Object what, int start, int end, int flags)
Mark the specified range of text with the specified object.
The flags determine how the span will behave when text is
inserted at the start or end of the span's range.
public
CharSequence
subSequence(int start, int end)
Return a new CharSequence containing a copy of the specified
range of this buffer, including the overlapping spans.
public
String
toString()
Return a String containing a copy of the chars in this buffer.
Returns
- String a printable representation for the receiver.