TextLinks
class TextLinks : Parcelable
| kotlin.Any | |
| ↳ | 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 | |
|---|---|
|
A builder to construct a TextLinks instance. |
|
|
A request object for generating TextLinks. |
|
|
A link, identifying a substring of text and possible entity types for it. |
|
|
A ClickableSpan for a TextLink. |
|
| Constants | |
|---|---|
| static Int |
Do not replace |
| static Int |
Replace any |
| static Int |
The specified text does not match the text used to generate the links. |
| static Int |
Links were successfully applied to the text. |
| static Int |
No links applied to text. |
| static Int |
No links exist to apply to text. |
| static Int |
The specified text contains unsupported characters. |
| Inherited constants | |
|---|---|
| Public methods | |
|---|---|
| Int |
apply(text: Spannable, applyStrategy: Int, spanFactory: Function<TextLinks.TextLink!, TextLinks.TextLinkSpan!>?)Annotates the given text with the generated links. |
| Int | |
| Bundle |
Returns the extended data. |
| MutableCollection<TextLinks.TextLink!> |
getLinks()Returns an unmodifiable Collection of the links. |
| CharSequence |
getText()Returns the text that was used to generate these links. |
| String |
toString() |
| Unit |
writeToParcel(dest: Parcel, flags: Int) |
| Properties | |
|---|---|
| static Parcelable.Creator<TextLinks!> | |
Constants
APPLY_STRATEGY_IGNORE
static val APPLY_STRATEGY_IGNORE: Int
Do not replace ClickableSpans that exist where the TextLinkSpan needs to be applied to. Do not apply the TextLinkSpan.
Value: 0APPLY_STRATEGY_REPLACE
static val APPLY_STRATEGY_REPLACE: Int
Replace any ClickableSpans that exist where the TextLinkSpan needs to be applied to.
Value: 1STATUS_DIFFERENT_TEXT
static val STATUS_DIFFERENT_TEXT: Int
The specified text does not match the text used to generate the links.
Value: 3STATUS_LINKS_APPLIED
static val STATUS_LINKS_APPLIED: Int
Links were successfully applied to the text.
Value: 0STATUS_NO_LINKS_APPLIED
static val STATUS_NO_LINKS_APPLIED: Int
No links applied to text. The links were filtered out.
Value: 2STATUS_NO_LINKS_FOUND
static val STATUS_NO_LINKS_FOUND: Int
No links exist to apply to text. Links count is zero.
Value: 1STATUS_UNSUPPORTED_CHARACTER
static val STATUS_UNSUPPORTED_CHARACTER: Int
The specified text contains unsupported characters.
Value: 4Public methods
apply
fun apply(
text: Spannable,
applyStrategy: Int,
spanFactory: Function<TextLinks.TextLink!, TextLinks.TextLinkSpan!>?
): Int
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 android.view.textclassifier.TextLinks#APPLY_STRATEGY_IGNORE, or android.view.textclassifier.TextLinks#APPLY_STRATEGY_REPLACE |
spanFactory |
Function<TextLinks.TextLink!, TextLinks.TextLinkSpan!>?: a custom span factory for converting TextLinks to TextLinkSpans. Set to null to use the default span factory. |
| Return | |
|---|---|
Int |
a status code indicating whether or not the links were successfully applied e.g. STATUS_LINKS_APPLIED Value is android.view.textclassifier.TextLinks#STATUS_LINKS_APPLIED, android.view.textclassifier.TextLinks#STATUS_NO_LINKS_FOUND, android.view.textclassifier.TextLinks#STATUS_NO_LINKS_APPLIED, android.view.textclassifier.TextLinks#STATUS_DIFFERENT_TEXT, or android.view.textclassifier.TextLinks#STATUS_UNSUPPORTED_CHARACTER |
describeContents
fun describeContents(): Int
| Return | |
|---|---|
Int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR |
getExtras
fun getExtras(): Bundle
Returns the extended data.
NOTE: Do not modify this bundle.
| Return | |
|---|---|
Bundle |
This value cannot be null. |
getLinks
fun getLinks(): MutableCollection<TextLinks.TextLink!>
Returns an unmodifiable Collection of the links.
| Return | |
|---|---|
MutableCollection<TextLinks.TextLink!> |
This value cannot be null. |
getText
fun getText(): CharSequence
Returns the text that was used to generate these links.
| Return | |
|---|---|
CharSequence |
This value cannot be null. |
toString
fun toString(): String
| Return | |
|---|---|
String |
a string representation of the object. |
writeToParcel
fun writeToParcel(
dest: Parcel,
flags: Int
): Unit
| 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_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |