ClickableSpan

@RequiresCarApi(value = 2)
@CarProtocol
class ClickableSpan : CarSpan


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 functions

java-static ClickableSpan
create(onClickListener: OnClickListener)

Creates a ClickableSpan from a OnClickListener.

Boolean
equals(other: Any?)
OnClickDelegate

Returns the OnClickDelegate associated with this span.

Int
String

Public functions

create

Added in 1.0.0
java-static fun create(onClickListener: OnClickListener): ClickableSpan

Creates a ClickableSpan from a OnClickListener.

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

Throws
java.lang.NullPointerException

if onClickListener is null

equals

Added in 1.4.0-rc02
fun equals(other: Any?): Boolean

getOnClickDelegate

Added in 1.0.0
fun getOnClickDelegate(): OnClickDelegate

Returns the OnClickDelegate associated with this span.

hashCode

Added in 1.4.0-rc02
fun hashCode(): Int

toString

Added in 1.4.0-rc02
fun toString(): String