AI-generated Key Takeaways
-
SpannedString
is an immutable class for text and markup, offering an alternative to mutable options likeSpannableString
andSpannableStringBuilder
. -
It provides methods to access and navigate text, including
charAt
,length
,subSequence
, andgetChars
. -
Developers can retrieve information about attached markup objects through methods like
getSpanStart
,getSpanEnd
,getSpanFlags
, andgetSpans
. -
SpannedString
inherits functionalities from interfaces such asCharSequence
,GetChars
, andSpanned
, extending its capabilities. -
Various span types and flags are defined within
Spanned
, influencing the behavior of markup objects within the text.
implements CharSequence CharSequence GetChars Spanned
This is the class for text whose content and markup are immutable.
For mutable markup, see SpannableString
; for mutable text,
see SpannableStringBuilder
.
Inherited Constant Summary
Public Constructor Summary
SpannedString(CharSequence source)
|
Public Method Summary
final char |
charAt(int i)
|
boolean |
equals(Object o)
|
final void |
getChars(int start, int end, char[] dest, int off)
Exactly like String.getChars(): copy chars
start
through end - 1 from this CharSequence into dest
beginning at offset destoff . |
int |
getSpanEnd(Object what)
Return the end of the range of text to which the specified
markup object is attached, or -1 if the object is not attached.
|
int |
getSpanFlags(Object what)
Return the flags that were specified when
Spannable.setSpan(Object, int, int, int) was
used to attach the specified markup object, or 0 if the specified
object has not been attached. |
int |
getSpanStart(Object what)
Return the beginning of the range of text to which the specified
markup object is attached, or -1 if the object is not attached.
|
<T> T[] |
getSpans(int queryStart, int queryEnd, Class<T> kind)
Return an array of the markup objects attached to the specified
slice of this CharSequence and whose type is the specified type
or a subclass of it.
|
int |
hashCode()
|
final int |
length()
|
int |
nextSpanTransition(int start, int limit, Class kind)
Return the first offset greater than or equal to
start
where a markup object of class type begins or ends,
or limit if there are no starts or ends greater than or
equal to start but less than limit . |
CharSequence |
subSequence(int start, int end)
|
final String |
toString()
|
static SpannedString |
valueOf(CharSequence source)
|
Inherited Method Summary
Public Constructors
public SpannedString (CharSequence source)
Parameters
source |
---|
Public Methods
public final char charAt (int i)
Parameters
i |
---|
public boolean equals (Object o)
Parameters
o |
---|
public final void getChars (int start, int end, char[] dest, int off)
Exactly like String.getChars(): copy chars start
through end - 1
from this CharSequence into dest
beginning at offset destoff
.
Parameters
start | |
---|---|
end | |
dest | |
off |
public int getSpanEnd (Object what)
Return the end of the range of text to which the specified markup object is attached, or -1 if the object is not attached.
Parameters
what |
---|
public int getSpanFlags (Object what)
Return the flags that were specified when Spannable.setSpan(Object, int, int, int)
was
used to attach the specified markup object, or 0 if the specified
object has not been attached.
Parameters
what |
---|
public int getSpanStart (Object what)
Return the beginning of the range of text to which the specified markup object is attached, or -1 if the object is not attached.
Parameters
what |
---|
public T[] getSpans (int queryStart, int queryEnd, Class<T> kind)
Return an array of the markup objects attached to the specified slice of this CharSequence and whose type is the specified type or a subclass of it. Specify Object.class for the type if you want all the objects regardless of type.
Parameters
queryStart | |
---|---|
queryEnd | |
kind |
public int hashCode ()
public final int length ()
public int nextSpanTransition (int start, int limit, Class kind)
Return the first offset greater than or equal to start
where a markup object of class type
begins or ends,
or limit
if there are no starts or ends greater than or
equal to start
but less than limit
. Specify
null
or Object.class for the type if you want every
transition regardless of type.
Parameters
start | |
---|---|
limit | |
kind |
public CharSequence subSequence (int start, int end)
Parameters
start | |
---|---|
end |