Language

TextUtils Class

Definition

Provides operations for text ranges, spans, searches, and text formatting.

[Android.Runtime.Register("android/text/TextUtils", DoNotGenerateAcw=true)]
public class TextUtils : Java.Lang.Object
[<Android.Runtime.Register("android/text/TextUtils", DoNotGenerateAcw=true)>]
type TextUtils = class
    inherit Object
Inheritance
Attributes

Remarks

Android platform documentation

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Name Description
TextUtils(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Fields

Name Description
SafeStringFlagFirstLine
Obsolete.

Return only first line of text (truncate at first newline).

SafeStringFlagSingleLine
Obsolete.

Force entire string into single line of text (no newlines).

SafeStringFlagTrim
Obsolete.

Remove Character#isWhitespace(int) whitespace and non-breaking spaces from the edges of the label.

Properties

Name Description
CharSequenceCreator

Gets the parcel reader for text written by this utility.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode

Gets the identity hash code assigned to this Java peer by the interop runtime.

(Inherited from Object)
JniManagedPeerState

Gets the state flags last assigned by the runtime.

(Inherited from JavaObject)
JniPeerMembers

Gets the JNI metadata used to access members of this Java binding.

PeerReference

Gets the JNI object reference for this Java peer.

(Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

Name Description
Clone()

Creates and returns a copy of this object.

(Inherited from Object)
CommaEllipsize(String, TextPaint, Single, String, String)

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".

CommaEllipsizeFormatted(ICharSequence, TextPaint, Single, String, String)

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".

Concat(String[])

Returns a CharSequence concatenating the specified CharSequences, retaining their spans if any.

ConcatFormatted(ICharSequence[])

Returns a CharSequence concatenating the specified CharSequences, retaining their spans if any.

Construct(JniObjectReference, JniObjectReferenceOptions)

Delegates construction of this peer to the runtime's value manager.

(Inherited from JavaObject)
CopySpansFrom(ISpanned, Int32, Int32, Class, ISpannable, Int32)

Copies the spans from the region start...end in source to the region destoff...destoff+end-start in dest.

Dispose()

Releases the resources held by this Java peer.

(Inherited from Object)
Dispose(Boolean)

Releases the resources held by this Java peer.

(Inherited from Object)
DisposeUnlessReferenced()

Asks the value manager to dispose this peer unless its mapping retains this same managed instance.

(Inherited from JavaObject)
DumpSpans(ICharSequence, IPrinter, String)

Debugging tool to print the spans in a CharSequence.

DumpSpans(String, IPrinter, String)

Debugging tool to print the spans in a CharSequence.

Ellipsize(String, TextPaint, Single, TextUtils+TruncateAt, Boolean, TextUtils+IEllipsizeCallback)

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.

Ellipsize(String, TextPaint, Single, TextUtils+TruncateAt)

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.

EllipsizeFormatted(ICharSequence, TextPaint, Single, TextUtils+TruncateAt, Boolean, TextUtils+IEllipsizeCallback)

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.

EllipsizeFormatted(ICharSequence, TextPaint, Single, TextUtils+TruncateAt)

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.

Equals(ICharSequence, ICharSequence)

Returns true if a and b are equal, including if they are both null.

Equals(Object)

Tests whether another managed peer refers to the same Java object.

(Inherited from JavaObject)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
Equals(String, String)

Returns true if a and b are equal, including if they are both null.

ExpandTemplate(String, String[])

Replace instances of "^1", "^2", etc.

ExpandTemplateFormatted(ICharSequence, ICharSequence[])

Replace instances of "^1", "^2", etc.

GetCapsMode(ICharSequence, Int32, CapitalizationMode)

Determine what caps mode should be in effect at the current offset in the text.

GetCapsMode(String, Int32, CapitalizationMode)

Determine what caps mode should be in effect at the current offset in the text.

GetChars(ICharSequence, Int32, Int32, Char[], Int32)

Copies a range of characters into an array.

GetChars(String, Int32, Int32, Char[], Int32)

Copies a range of characters into an array.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetLayoutDirectionFromLocale(Locale)

Return the layout direction for a given Locale

GetOffsetAfter(ICharSequence, Int32)

Finds the next text offset without splitting a surrogate pair or replacement span.

GetOffsetAfter(String, Int32)

Finds the next text offset without splitting a surrogate pair.

GetOffsetBefore(ICharSequence, Int32)

Finds the preceding text offset without splitting a surrogate pair or replacement span.

GetOffsetBefore(String, Int32)

Finds the preceding text offset without splitting a surrogate pair.

GetReverse(String, Int32, Int32)
Obsolete.

This function only reverses individual chars and not their associated spans.

GetReverseFormatted(ICharSequence, Int32, Int32)
Obsolete.

This function only reverses individual chars and not their associated spans.

GetTrimmedLength(ICharSequence)

Returns the length that the specified CharSequence would have if spaces and ASCII control characters were trimmed from the start and end, as by String#trim.

GetTrimmedLength(String)

Returns the length that the specified CharSequence would have if spaces and ASCII control characters were trimmed from the start and end, as by String#trim.

HtmlEncode(String)

Html-encode the string.

IndexOf(ICharSequence, Char, Int32, Int32)

Finds a character within the specified text range.

IndexOf(ICharSequence, Char, Int32)

Finds a character at or after the specified index.

IndexOf(ICharSequence, Char)

Finds the first occurrence of a character.

IndexOf(ICharSequence, ICharSequence, Int32, Int32)

Finds a character sequence within the specified text range.

IndexOf(ICharSequence, ICharSequence, Int32)

Finds a character sequence at or after the specified index.

IndexOf(ICharSequence, ICharSequence)

Finds the first occurrence of a character sequence.

IndexOf(String, Char, Int32, Int32)

Finds a character within the specified text range.

IndexOf(String, Char, Int32)

Finds a character at or after the specified index.

IndexOf(String, Char)

Finds the first occurrence of a character.

IndexOf(String, String, Int32, Int32)

Finds a character sequence within the specified text range.

IndexOf(String, String, Int32)

Finds a character sequence at or after the specified index.

IndexOf(String, String)

Finds the first occurrence of a character sequence.

IsDigitsOnly(ICharSequence)

Returns whether the given CharSequence contains only digits.

IsDigitsOnly(String)

Returns whether the given CharSequence contains only digits.

IsEmpty(ICharSequence)

Returns true if the string is null or 0-length.

IsEmpty(String)

Returns true if the string is null or 0-length.

IsGraphic(Char)
Obsolete.

Returns whether this character is a printable character.

IsGraphic(ICharSequence)

Returns whether the given CharSequence contains any printable characters.

IsGraphic(String)

Returns whether the given CharSequence contains any printable characters.

JavaFinalize()
Obsolete.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Join(ICharSequence, IIterable)

Returns a string containing the tokens joined by delimiters.

Join(ICharSequence, Object[])

Returns a string containing the tokens joined by delimiters.

Join(String, IIterable)

Returns a string containing the tokens joined by delimiters.

Join(String, Object[])

Returns a string containing the tokens joined by delimiters.

LastIndexOf(ICharSequence, Char, Int32, Int32)

Searches backward for a character within an inclusive index range.

LastIndexOf(ICharSequence, Char, Int32)

Finds the last occurrence of a character at or before an index.

LastIndexOf(ICharSequence, Char)

Finds the last occurrence of a character.

LastIndexOf(String, Char, Int32, Int32)

Searches backward for a character within an inclusive index range.

LastIndexOf(String, Char, Int32)

Finds the last occurrence of a character at or before an index.

LastIndexOf(String, Char)

Finds the last occurrence of a character.

MakeSafeForPresentation(String, Int32, Single, SafeStringFlagMode)

Remove html, remove bad characters, and truncate string.

MakeSafeForPresentationFormatted(String, Int32, Single, SafeStringFlagMode)

Remove html, remove bad characters, and truncate string.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
RegionMatches(ICharSequence, Int32, ICharSequence, Int32, Int32)

Compares two text ranges character by character.

RegionMatches(String, Int32, String, Int32, Int32)

Compares two text ranges character by character.

Replace(String, String[], String[])

Return a new CharSequence in which each of the source strings is replaced by the corresponding element of the destinations.

ReplaceFormatted(ICharSequence, String[], ICharSequence[])

Return a new CharSequence in which each of the source strings is replaced by the corresponding element of the destinations.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetPeerReference(JniObjectReference, JniObjectReferenceOptions)

Stores a reference value in the control block without creating a JNI reference copy.

(Inherited from JavaObject)
Split(String, Pattern)

Splits a string on a pattern.

Split(String, String)

This method yields the same result as text.split(expression, -1) except that if text.isEmpty() then this method returns an empty array whereas "".split(expression, -1) would have returned an array with a single "".

StringOrSpannedString(String)

Gets a string representation of the supplied text.

StringOrSpannedStringFormatted(ICharSequence)

Gets an immutable string or spanned string for a character sequence.

Substring(ICharSequence, Int32, Int32)

Create a new String object containing the given range of characters from the source string.

Substring(String, Int32, Int32)

Create a new String object containing the given range of characters from the source string.

ToArray<T>()

Creates a managed array from this Java array wrapper.

(Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime()

Unregisters this Java peer from the interop runtime.

(Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WriteToParcel(ICharSequence, Parcel, ParcelableWriteFlags)

Flatten a CharSequence and whatever styles can be copied across processes into the parcel.

WriteToParcel(String, Parcel, ParcelableWriteFlags)

Flatten a CharSequence and whatever styles can be copied across processes into the parcel.

Explicit Interface Implementations

Name Description
IJavaPeerable.Disposed()

Marks this peer as disposed and calls Dispose with disposing set to true.

(Inherited from JavaObject)
IJavaPeerable.Finalized()

Marks this peer as disposed and calls Dispose with disposing set to false.

(Inherited from JavaObject)
IJavaPeerable.JniObjectReferenceControlBlock

Gets the native control-block pointer used by this peer.

(Inherited from JavaObject)
IJavaPeerable.SetJniIdentityHashCode(Int32)

Stores the identity hash code supplied by the runtime.

(Inherited from JavaObject)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates)

Replaces the stored managed peer state flags.

(Inherited from JavaObject)
IJavaPeerable.SetPeerReference(JniObjectReference)

Updates the peer reference and releases a disposed peer's control block when the reference is invalid.

(Inherited from JavaObject)

Extension Methods

Name Description
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)

Reuses a compatible managed peer or obtains a wrapper of the requested type.

TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to