Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

TextLinks.DefaultTextLinkSpan

public static class TextLinks.DefaultTextLinkSpan
extends TextLinks.TextLinkSpan

java.lang.Object
   ↳ android.text.style.CharacterStyle
     ↳ android.text.style.ClickableSpan
       ↳ androidx.textclassifier.TextLinks.TextLinkSpan
         ↳ androidx.textclassifier.TextLinks.DefaultTextLinkSpan


The default implementation of TextLinks.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

TextLinks.DefaultTextLinkSpan(TextLinks.TextLinkSpanData textLinkSpanData)

Constructs a DefaultTextLinkSpan.

Public methods

void onClick(View widget)

Performs the click action associated with this span.

void onTextClassificationResult(TextView textView, TextClassification textClassification)

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

Inherited methods

Public constructors

TextLinks.DefaultTextLinkSpan

public TextLinks.DefaultTextLinkSpan (TextLinks.TextLinkSpanData textLinkSpanData)

Constructs a DefaultTextLinkSpan.

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

Public methods

onClick

public void onClick (View widget)

Performs the click action associated with this span.

Subclass implementations should always call through to the superclass implementation.

Parameters
widget View

onTextClassificationResult

public void onTextClassificationResult (TextView textView, 
                TextClassification textClassification)

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 TextClassification: the text classification result of the text in this span.