java.lang.Object | |
↳ | android.text.TextUtils |
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
TextUtils.EllipsizeCallback | |||||||||||
TextUtils.SimpleStringSplitter | A simple string splitter. | ||||||||||
TextUtils.StringSplitter | An interface for splitting strings according to rules that are opaque to the user of this interface. | ||||||||||
TextUtils.TruncateAt |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | CAP_MODE_CHARACTERS | Capitalization mode for getCapsMode(CharSequence, int, int) : capitalize all
characters. |
|||||||||
int | CAP_MODE_SENTENCES | Capitalization mode for getCapsMode(CharSequence, int, int) : capitalize the first
character of each sentence. |
|||||||||
int | CAP_MODE_WORDS | Capitalization mode for getCapsMode(CharSequence, int, int) : capitalize the first
character of all words. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CHAR_SEQUENCE_CREATOR |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Converts a CharSequence of the comma-separated form "Andy, Bob,
Charles, David" that is too wide to fit into the specified width
into one like "Andy, Bob, 2 more".
| |||||||||||
Returns a CharSequence concatenating the specified CharSequences,
retaining their spans if any.
| |||||||||||
Copies the spans from the region
start...end in
source to the region
destoff...destoff+end-start in dest . | |||||||||||
Debugging tool to print the spans in a CharSequence.
| |||||||||||
Returns the original text if it fits in the specified width
given the properties of the specified Paint,
or, if it does not fit, a truncated
copy with ellipsis character added at the specified edge or center.
| |||||||||||
Returns the original text if it fits in the specified width
given the properties of the specified Paint,
or, if it does not fit, a copy with ellipsis character added
at the specified edge or center.
| |||||||||||
Returns true if a and b are equal, including if they are both null.
| |||||||||||
Replace instances of "^1", "^2", etc.
| |||||||||||
Determine what caps mode should be in effect at the current offset in
the text.
| |||||||||||
Return the layout direction for a given Locale
| |||||||||||
Returns the length that the specified CharSequence would have if
spaces and control characters were trimmed from the start and end,
as by
trim() . | |||||||||||
Html-encode the string.
| |||||||||||
Returns whether the given CharSequence contains only digits.
| |||||||||||
Returns true if the string is null or 0-length.
| |||||||||||
Returns whether the given CharSequence contains any printable characters.
| |||||||||||
Returns whether this character is a printable character.
| |||||||||||
Returns a string containing the tokens joined by delimiters.
| |||||||||||
Returns a string containing the tokens joined by delimiters.
| |||||||||||
Return a new CharSequence in which each of the source strings is
replaced by the corresponding element of the destinations.
| |||||||||||
Splits a string on a pattern.
| |||||||||||
String.split() returns [''] when the string to be split is empty.
| |||||||||||
Create a new String object containing the given range of characters
from the source string.
| |||||||||||
Flatten a CharSequence and whatever styles can be copied across processes
into the parcel.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Capitalization mode for getCapsMode(CharSequence, int, int)
: capitalize all
characters. This value is explicitly defined to be the same as
TYPE_TEXT_FLAG_CAP_CHARACTERS
.
Capitalization mode for getCapsMode(CharSequence, int, int)
: capitalize the first
character of each sentence. This value is explicitly defined to be the same as
TYPE_TEXT_FLAG_CAP_SENTENCES
.
Capitalization mode for getCapsMode(CharSequence, int, int)
: capitalize the first
character of all words. This value is explicitly defined to be the same as
TYPE_TEXT_FLAG_CAP_WORDS
.
Converts a CharSequence of the comma-separated form "Andy, Bob, Charles, David" that is too wide to fit into the specified width into one like "Andy, Bob, 2 more".
text | the text to truncate |
---|---|
p | the Paint with which to measure the text |
avail | the horizontal width available for the text |
oneMore | the string for "1 more" in the current locale |
more | the string for "%d more" in the current locale |
Returns a CharSequence concatenating the specified CharSequences, retaining their spans if any.
Copies the spans from the region start...end
in
source
to the region
destoff...destoff+end-start
in dest
.
Spans in source
that begin before start
or end after end
but overlap this range are trimmed
as if they began at start
or ended at end
.
IndexOutOfBoundsException | if any of the copied spans
are out of range in dest .
|
---|
Debugging tool to print the spans in a CharSequence. The output will be printed one span per line. If the CharSequence is not a Spanned, then the entire string will be printed on a single line.
Returns the original text if it fits in the specified width given the properties of the specified Paint, or, if it does not fit, a truncated copy with ellipsis character added at the specified edge or center.
Returns the original text if it fits in the specified width
given the properties of the specified Paint,
or, if it does not fit, a copy with ellipsis character added
at the specified edge or center.
If preserveLength
is specified, the returned copy
will be padded with zero-width spaces to preserve the original
length and offsets instead of truncating.
If callback
is non-null, it will be called to
report the start and end of the ellipsized range. TextDirection
is determined by the first strong directional character.
Returns true if a and b are equal, including if they are both null.
Note: In platform versions 1.1 and earlier, this method only worked well if both the arguments were instances of String.
a | first CharSequence to check |
---|---|
b | second CharSequence to check |
Replace instances of "^1", "^2", etc. in the
template
CharSequence with the corresponding
values
. "^^" is used to produce a single caret in
the output. Only up to 9 replacement values are supported,
"^10" will be produce the first replacement value followed by a
'0'.
template | the input text containing "^1"-style placeholder values. This object is not modified; a copy is returned. |
---|---|
values | CharSequences substituted into the template. The first is substituted for "^1", the second for "^2", and so on. |
IllegalArgumentException | if the template requests a value that was not provided, or if more than 9 values are provided. |
---|
Determine what caps mode should be in effect at the current offset in
the text. Only the mode bits set in reqModes will be
checked. Note that the caps mode flags here are explicitly defined
to match those in InputType
.
cs | The text that should be checked for caps modes. |
---|---|
off | Location in the text at which to check. |
reqModes | The modes to be checked: may be any combination of
CAP_MODE_CHARACTERS , CAP_MODE_WORDS , and
CAP_MODE_SENTENCES . |
CAP_MODE_CHARACTERS
, CAP_MODE_WORDS
, and
CAP_MODE_SENTENCES
.
Return the layout direction for a given Locale
locale | the Locale for which we want the layout direction. Can be null. |
---|
LAYOUT_DIRECTION_LTR
or
LAYOUT_DIRECTION_RTL
.
Be careful: this code will need to be updated when vertical scripts will be supported
Returns the length that the specified CharSequence would have if
spaces and control characters were trimmed from the start and end,
as by trim()
.
Html-encode the string.
s | the string to be encoded |
---|
Returns whether the given CharSequence contains only digits.
Returns true if the string is null or 0-length.
str | the string to be examined |
---|
Returns whether the given CharSequence contains any printable characters.
Returns whether this character is a printable character.
Returns a string containing the tokens joined by delimiters.
tokens | an array objects to be joined. Strings will be formed from the objects by calling object.toString(). |
---|
Returns a string containing the tokens joined by delimiters.
tokens | an array objects to be joined. Strings will be formed from the objects by calling object.toString(). |
---|
Return a new CharSequence in which each of the source strings is replaced by the corresponding element of the destinations.
Splits a string on a pattern. String.split() returns [''] when the string to be split is empty. This returns []. This does not remove any empty strings from the result.
text | the string to split |
---|---|
pattern | the regular expression to match |
NullPointerException | if expression or text is null |
---|
String.split() returns [''] when the string to be split is empty. This returns []. This does not remove any empty strings from the result. For example split("a,", "," ) returns {"a", ""}.
text | the string to split |
---|---|
expression | the regular expression to match |
NullPointerException | if expression or text is null |
---|
Create a new String object containing the given range of characters
from the source string. This is different than simply calling
CharSequence.subSequence
in that it does not preserve any style runs in the source sequence,
allowing a more efficient implementation.
Flatten a CharSequence and whatever styles can be copied across processes into the parcel.