Register now for Android Dev Summit 2019!

DefaultTextLinkSpan

class DefaultTextLinkSpan : TextLinks.TextLinkSpan
kotlin.Any
   ↳ android.text.style.CharacterStyle
   ↳ android.text.style.ClickableSpan
   ↳ androidx.textclassifier.TextLinks.TextLinkSpan
   ↳ androidx.textclassifier.TextLinks.DefaultTextLinkSpan

The default implementation of TextLinkSpan.

When this span is clicked, text classifier will be used to classify the text in the span and suggest possible actions. The suggested actions will be presented to users eventually. You can change the way how the suggested actions are presented to user by overriding onTextClassificationResult(TextView, TextClassification).

Summary

Public constructors

<init>(@NonNull textLinkSpanData: TextLinks.TextLinkSpanData)

Constructs a DefaultTextLinkSpan.

Public methods

open Unit
onClick(@NonNull widget: View)

Performs the click action associated with this span.

open Unit
onTextClassificationResult(@NonNull textView: TextView, @NonNull textClassification: TextClassification)

Invoked when the classification of the text of this span is available.

Inherited functions

Public constructors

<init>

DefaultTextLinkSpan(@NonNull textLinkSpanData: TextLinks.TextLinkSpanData)

Constructs a DefaultTextLinkSpan.

Parameters
textLinkSpanData TextLinks.TextLinkSpanData: The data object that contains data of this span, like the text link.

Public methods

onClick

@CallSuper open fun onClick(@NonNull widget: View): Unit

Performs the click action associated with this span.

Subclass implementations should always call through to the superclass implementation.

onTextClassificationResult

@UiThread open fun onTextClassificationResult(@NonNull textView: TextView, @NonNull textClassification: TextClassification): Unit

Invoked when the classification of the text of this span is available.

When user clicks on this span, text classifier will be used to classify the text of this span. Once text classifier has the result, this callback will be invoked. If the text in the textview is changed during the text classification, this won't be invoked.

You can change the way how the suggested actions are presented to user by overriding this function.

Parameters
textView TextView: the textview that this span is attached to
textClassification TextView: the text classification result of the text in this span.