TextLinks
class TextLinks
kotlin.Any | |
↳ | androidx.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. |
|
The default implementation of |
|
A request object for generating TextLinks. |
|
abstract |
A factory to create spans from TextLinks. |
A link, identifying a substring of text and possible entity types for it. |
|
abstract |
A ClickableSpan for a TextLink. |
Contains necessary data for |
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 |
Status unknown. |
Public methods | |
---|---|
Int |
apply(@NonNull text: Spannable, @NonNull textClassifier: TextClassifier, @NonNull textLinksParams: TextLinksParams) Annotates the given text with the generated links. |
static TextLinks |
createFromBundle(@NonNull bundle: Bundle) Extracts an TextLinks object from a bundle that was added using |
Bundle |
Returns the extended, vendor specific data. |
MutableCollection<TextLinks.TextLink!> |
getLinks() Returns an unmodifiable Collection of the links. |
CharSequence |
getText() Returns the text that was used to generate these links. |
Bundle |
toBundle() Adds a TextLinks object to a Bundle that can be read back with the same parameters to |
String |
toString() |
Constants
APPLY_STRATEGY_IGNORE
static val APPLY_STRATEGY_IGNORE: Int
Do not replace ClickableSpan
s that exist where the TextLinkSpan
needs to be applied to. Do not apply the TextLinkSpan.
Value: 0
APPLY_STRATEGY_REPLACE
static val APPLY_STRATEGY_REPLACE: Int
Replace any ClickableSpan
s that exist where the TextLinkSpan
needs to be applied to.
Value: 1
STATUS_DIFFERENT_TEXT
static val STATUS_DIFFERENT_TEXT: Int
The specified text does not match the text used to generate the links.
Value: 3
STATUS_LINKS_APPLIED
static val STATUS_LINKS_APPLIED: Int
Links were successfully applied to the text.
Value: 0
STATUS_NO_LINKS_APPLIED
static val STATUS_NO_LINKS_APPLIED: Int
No links applied to text. The links were filtered out.
Value: 2
STATUS_NO_LINKS_FOUND
static val STATUS_NO_LINKS_FOUND: Int
No links exist to apply to text. Links count is zero.
Value: 1
Public methods
apply
fun apply(
@NonNull text: Spannable,
@NonNull textClassifier: TextClassifier,
@NonNull textLinksParams: TextLinksParams
): Int
Annotates the given text with the generated links.
NOTE: It may be necessary to set a LinkMovementMethod on the TextView widget to properly handle links. See TextView#setMovementMethod(MovementMethod)
. It is also necessary that the TextView be focusable. See TextView#setFocusable(boolean)
} and TextView#setFocusableInTouchMode(boolean)
.
Parameters | |
---|---|
text |
Spannable: the text to apply the links to. Must match the original text |
textClassifier |
TextClassifier: the TextClassifier to use to classify a clicked link. Should usually be the one used to generate the links |
textLinksParams |
TextLinksParams: the param that specifies how the links should be applied |
Return | |
---|---|
Int |
the status code which indicates the operation is success or not. |