ClickableSpan

public final class ClickableSpan
extends CarSpan

java.lang.Object
   ↳ android.text.style.CharacterStyle
     ↳ androidx.car.app.model.CarSpan
       ↳ androidx.car.app.model.ClickableSpan


A span that makes a section of text clickable.

The text of this span will be highlighted by the host, so users understand that it is interactive. If this span overlaps the other spans (for example, ForegroundCarColorSpan), the host might choose to ignore those spans if they conflict on how clickable text is highlighted.

The host may ignore ClickableSpans unless support for it is explicitly documented in the API that takes the string.

For example, to make a portion of a text clickable:

SpannableString string = new SpannableString("Text with a clickable span");
 string.setSpan(ClickableSpan.create(
     new OnClickListener
     ), 12, 22, Spanned.SPAN_INCLUSIVE_EXCLUSIVE));
 

Summary

Public methods

static ClickableSpan create(OnClickListener onClickListener)

Creates a ClickableSpan from a OnClickListener.

boolean equals(Object other)
OnClickDelegate getOnClickDelegate()

Returns the OnClickDelegate associated with this span.

int hashCode()
String toString()

Inherited methods

Public methods

create

public static ClickableSpan create (OnClickListener onClickListener)

Creates a ClickableSpan from a OnClickListener.

Note that the callback relates to UI events and will be executed on the main thread using Looper.getMainLooper().

Parameters
onClickListener OnClickListener

Returns
ClickableSpan

Throws
NullPointerException if onClickListener is null

equals

public boolean equals (Object other)

Parameters
other Object

Returns
boolean

getOnClickDelegate

public OnClickDelegate getOnClickDelegate ()

Returns the OnClickDelegate associated with this span.

Returns
OnClickDelegate

hashCode

public int hashCode ()

Returns
int

toString

public String toString ()

Returns
String