# ClickableSpan

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/text/style/ClickableSpan#pubctors)\|[Methods](https://developer.android.com/reference/android/text/style/ClickableSpan#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/text/style/ClickableSpan#inhmethods)  

# ClickableSpan

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/text/style/ClickableSpan "View this page in Kotlin")\|Java

`
public


abstract
class
ClickableSpan
`  
`


``

extends `[CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle)`


``


implements

`[UpdateAppearance](https://developer.android.com/reference/android/text/style/UpdateAppearance)`


`

|---|---|----------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.text.style.CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle) ||
|   | ↳ | android.text.style.ClickableSpan |

|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known direct subclasses [TextLinks.TextLinkSpan](https://developer.android.com/reference/android/view/textclassifier/TextLinks.TextLinkSpan),[URLSpan](https://developer.android.com/reference/android/text/style/URLSpan) |----------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------| | [TextLinks.TextLinkSpan](https://developer.android.com/reference/android/view/textclassifier/TextLinks.TextLinkSpan) | A ClickableSpan for a TextLink.                                                                                                                 | | [URLSpan](https://developer.android.com/reference/android/text/style/URLSpan)                                        | Implementation of the[ClickableSpan](https://developer.android.com/reference/android/text/style/ClickableSpan)that allows setting a url string. | |

<br />

*** ** * ** ***

If an object of this type is attached to the text of a TextView with a movement method of LinkMovementMethod, the affected spans of text can be selected. If selected and clicked, the[onClick(View)](https://developer.android.com/reference/android/text/style/ClickableSpan#onClick(android.view.View))method will be called.

The text with a`ClickableSpan`attached will be underlined and the link color will be used as a text color. The default link color is the theme's accent color or`android:textColorLink`if this attribute is defined in the theme. For example, considering that we have a`CustomClickableSpan`that extends`ClickableSpan`, it can be used like this:  

    SpannableString string = new SpannableString("Text with clickable text");
    string.setSpan(new CustomClickableSpan(), 10, 19, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

![](https://developer.android.com/static/reference/android/images/text/style/clickablespan.png)Text with`ClickableSpan`.

<br />

## Summary

|                                               ### Public constructors                                                ||
|-------------------------------------------------------------------------------------------------------------------|---|
| ` `[ClickableSpan](https://developer.android.com/reference/android/text/style/ClickableSpan#ClickableSpan())`() ` |

|                                                                                                                                                                 ### Public methods                                                                                                                                                                  ||
|-----------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract void`                                                      | ` `[onClick](https://developer.android.com/reference/android/text/style/ClickableSpan#onClick(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View)` widget) ` Performs the click action associated with this span.                        |
| ` `[String](https://developer.android.com/reference/java/lang/String) | ` `[toString](https://developer.android.com/reference/android/text/style/ClickableSpan#toString())`() ` Returns a string representation of the object.                                                                                                                       |
| ` void`                                                               | ` `[updateDrawState](https://developer.android.com/reference/android/text/style/ClickableSpan#updateDrawState(android.text.TextPaint))`(`[TextPaint](https://developer.android.com/reference/android/text/TextPaint)` ds) ` Makes the text underlined and in the link color. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[android.text.style.CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle)` ` |-------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle)        | ` `[getUnderlying](https://developer.android.com/reference/android/text/style/CharacterStyle#getUnderlying())`() ` Returns "this" for most CharacterStyles, but for CharacterStyles that were generated by[wrap(CharacterStyle)](https://developer.android.com/reference/android/text/style/CharacterStyle#wrap(android.text.style.CharacterStyle)), returns the underlying CharacterStyle. | | ` abstract void`                                                                                      | ` `[updateDrawState](https://developer.android.com/reference/android/text/style/CharacterStyle#updateDrawState(android.text.TextPaint))`(`[TextPaint](https://developer.android.com/reference/android/text/TextPaint)` tp) `                                                                                                                                                                | | ` static `[CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle) | ` `[wrap](https://developer.android.com/reference/android/text/style/CharacterStyle#wrap(android.text.style.CharacterStyle))`(`[CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle)` cs) ` A given CharacterStyle can only applied to a single region of a given Spanned.                                                                            | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### ClickableSpan

```
public ClickableSpan ()
```

<br />

<br />

## Public methods

### onClick

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void onClick (View widget)
```

Performs the click action associated with this span.

<br />

|                      Parameters                      ||
|----------|--------------------------------------------|
| `widget` | `View`: This value cannot be`null`. <br /> |

### toString

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String toString ()
```

Returns a string representation of the object.

<br />

|                                                      Returns                                                      ||
|--------------------------------------------------------------------|-----------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | a string representation of the object. <br /> |

### updateDrawState

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void updateDrawState (TextPaint ds)
```

Makes the text underlined and in the link color.

<br />

|                      Parameters                       ||
|------|-------------------------------------------------|
| `ds` | `TextPaint`: This value cannot be`null`. <br /> |