TextLinks
public
final
class
TextLinks
extends Object
implements
Parcelable
java.lang.Object | |
↳ | android.view.textclassifier.TextLinks |
A collection of links, representing subsequences of text and the entity types (phone number, address, url, etc) they may be.
Summary
Nested classes | |
---|---|
class |
TextLinks.Builder
A builder to construct a TextLinks instance. |
class |
TextLinks.Request
A request object for generating TextLinks. |
class |
TextLinks.TextLink
A link, identifying a substring of text and possible entity types for it. |
class |
TextLinks.TextLinkSpan
A ClickableSpan for a TextLink. |
Constants | |
---|---|
int |
APPLY_STRATEGY_IGNORE
Do not replace |
int |
APPLY_STRATEGY_REPLACE
Replace any |
int |
STATUS_DIFFERENT_TEXT
The specified text does not match the text used to generate the links. |
int |
STATUS_LINKS_APPLIED
Links were successfully applied to the text. |
int |
STATUS_NO_LINKS_APPLIED
No links applied to text. |
int |
STATUS_NO_LINKS_FOUND
No links exist to apply to text. |
int |
STATUS_UNSUPPORTED_CHARACTER
The specified text contains unsupported characters. |
Inherited constants |
---|
Fields | |
---|---|
public
static
final
Creator<TextLinks> |
CREATOR
|
Public methods | |
---|---|
int
|
apply(Spannable text, int applyStrategy, Function<TextLinks.TextLink, TextLinks.TextLinkSpan> spanFactory)
Annotates the given text with the generated links. |
int
|
describeContents()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
Bundle
|
getExtras()
Returns the extended data. |
Collection<TextLinks.TextLink>
|
getLinks()
Returns an unmodifiable Collection of the links. |
CharSequence
|
getText()
Returns the text that was used to generate these links. |
String
|
toString()
Returns a string representation of the object. |
void
|
writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel. |
Inherited methods | |
---|---|
Constants
APPLY_STRATEGY_IGNORE
public static final int APPLY_STRATEGY_IGNORE
Do not replace ClickableSpan
s that exist where the TextLinkSpan
needs to
be applied to. Do not apply the TextLinkSpan.
Constant Value: 0 (0x00000000)
APPLY_STRATEGY_REPLACE
public static final int APPLY_STRATEGY_REPLACE
Replace any ClickableSpan
s that exist where the TextLinkSpan
needs to be
applied to.
Constant Value: 1 (0x00000001)
STATUS_DIFFERENT_TEXT
public static final int STATUS_DIFFERENT_TEXT
The specified text does not match the text used to generate the links.
Constant Value: 3 (0x00000003)
STATUS_LINKS_APPLIED
public static final int STATUS_LINKS_APPLIED
Links were successfully applied to the text.
Constant Value: 0 (0x00000000)
STATUS_NO_LINKS_APPLIED
public static final int STATUS_NO_LINKS_APPLIED
No links applied to text. The links were filtered out.
Constant Value: 2 (0x00000002)
STATUS_NO_LINKS_FOUND
public static final int STATUS_NO_LINKS_FOUND
No links exist to apply to text. Links count is zero.
Constant Value: 1 (0x00000001)
STATUS_UNSUPPORTED_CHARACTER
public static final int STATUS_UNSUPPORTED_CHARACTER
The specified text contains unsupported characters.
Constant Value: 4 (0x00000004)
Fields
Public methods
apply
public int apply (Spannable text, int applyStrategy, Function<TextLinks.TextLink, TextLinks.TextLinkSpan> spanFactory)
Annotates the given text with the generated links. It will fail if the provided text doesn't match the original text used to create the TextLinks.
NOTE: It may be necessary to set a LinkMovementMethod on the TextView
widget to properly handle links. See TextView.setMovementMethod(MovementMethod)
Parameters | |
---|---|
text |
Spannable : the text to apply the links to. Must match the original text
This value cannot be null . |
applyStrategy |
int : the apply strategy used to determine how to apply links to text.
e.g TextLinks.APPLY_STRATEGY_IGNORE
Value is APPLY_STRATEGY_IGNORE , or APPLY_STRATEGY_REPLACE |
spanFactory |
Function : a custom span factory for converting TextLinks to TextLinkSpans.
Set to null to use the default span factory. |
Returns | |
---|---|
int |
a status code indicating whether or not the links were successfully applied
e.g. STATUS_LINKS_APPLIED
Value is STATUS_LINKS_APPLIED , STATUS_NO_LINKS_FOUND , STATUS_NO_LINKS_APPLIED , STATUS_DIFFERENT_TEXT , or STATUS_UNSUPPORTED_CHARACTER |
describeContents
public int describeContents ()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of writeToParcel(android.os.Parcel, int)
,
the return value of this method must include the
CONTENTS_FILE_DESCRIPTOR
bit.
Returns | |
---|---|
int |
a bitmask indicating the set of special object types marshaled
by this Parcelable object instance.
Value is either 0 or CONTENTS_FILE_DESCRIPTOR |
getExtras
public Bundle getExtras ()
Returns the extended data.
NOTE: Do not modify this bundle.
Returns | |
---|---|
Bundle |
This value cannot be null . |
getLinks
public Collection<TextLinks.TextLink> getLinks ()
Returns an unmodifiable Collection of the links.
Returns | |
---|---|
Collection<TextLinks.TextLink> |
This value cannot be null . |
getText
public CharSequence getText ()
Returns the text that was used to generate these links.
Returns | |
---|---|
CharSequence |
This value cannot be null . |
toString
public String toString ()
Returns a string representation of the object.
Returns | |
---|---|
String |
a string representation of the object. |
writeToParcel
public void writeToParcel (Parcel dest, int flags)
Flatten this object in to a Parcel.
Parameters | |
---|---|
dest |
Parcel : The Parcel in which the object should be written.
This value cannot be null . |
flags |
int : Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE .
Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-12-18 UTC.