Stay organized with collections
Save and categorize content based on your preferences.
SpanWatcher
interface SpanWatcher : NoCopySpan
When an object of this type is attached to a Spannable, its methods will be called to notify it that other markup objects have been added, changed, or removed.
Summary
Public methods |
abstract Unit |
This method is called to notify you that the specified object has been attached to the specified range of the text.
|
abstract Unit |
This method is called to notify you that the specified object has been relocated from the range ostart…oend to the new range nstart…nend of the text.
|
abstract Unit |
This method is called to notify you that the specified object has been detached from the specified range of the text.
|
Public methods
onSpanAdded
abstract fun onSpanAdded(
text: Spannable!,
what: Any!,
start: Int,
end: Int
): Unit
This method is called to notify you that the specified object has been attached to the specified range of the text.
onSpanChanged
abstract fun onSpanChanged(
text: Spannable!,
what: Any!,
ostart: Int,
oend: Int,
nstart: Int,
nend: Int
): Unit
This method is called to notify you that the specified object has been relocated from the range ostart…oend
to the new range nstart…nend
of the text.
onSpanRemoved
abstract fun onSpanRemoved(
text: Spannable!,
what: Any!,
start: Int,
end: Int
): Unit
This method is called to notify you that the specified object has been detached from the specified range of the text.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# SpanWatcher\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nSpanWatcher\n===========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/text/SpanWatcher \"View this page in Java\") \n\n```\ninterface SpanWatcher : NoCopySpan\n```\n\n|-------------------------------|\n| [android.text.SpanWatcher](#) |\n\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [MultiTapKeyListener](/reference/kotlin/android/text/method/MultiTapKeyListener), [TextKeyListener](/reference/kotlin/android/text/method/TextKeyListener) |----------------------------------------------------------------------------------|-----------------------------------------------------------------------------| | [MultiTapKeyListener](/reference/kotlin/android/text/method/MultiTapKeyListener) | This is the standard key listener for alphabetic input on 12-key keyboards. | | [TextKeyListener](/reference/kotlin/android/text/method/TextKeyListener) | This is the key listener for typing normal text. | |\n\nWhen an object of this type is attached to a Spannable, its methods will be called to notify it that other markup objects have been added, changed, or removed.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onSpanAdded](#onSpanAdded(android.text.Spannable,%20kotlin.Any,%20kotlin.Int,%20kotlin.Int))`(`text:` `[Spannable](/reference/kotlin/android/text/Spannable)!`, `what:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`, `start:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `end:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` This method is called to notify you that the specified object has been attached to the specified range of the text. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onSpanChanged](#onSpanChanged(android.text.Spannable,%20kotlin.Any,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int))`(`text:` `[Spannable](/reference/kotlin/android/text/Spannable)!`, `what:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`, `ostart:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `oend:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `nstart:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `nend:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` This method is called to notify you that the specified object has been relocated from the range `ostart...oend` to the new range `nstart...nend` of the text. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onSpanRemoved](#onSpanRemoved(android.text.Spannable,%20kotlin.Any,%20kotlin.Int,%20kotlin.Int))`(`text:` `[Spannable](/reference/kotlin/android/text/Spannable)!`, `what:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`, `start:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `end:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` This method is called to notify you that the specified object has been detached from the specified range of the text. |\n\nPublic methods\n--------------\n\n### onSpanAdded\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onSpanAdded(\n text: Spannable!, \n what: Any!, \n start: Int, \n end: Int\n): Unit\n```\n\nThis method is called to notify you that the specified object has been attached to the specified range of the text. \n\n### onSpanChanged\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onSpanChanged(\n text: Spannable!, \n what: Any!, \n ostart: Int, \n oend: Int, \n nstart: Int, \n nend: Int\n): Unit\n```\n\nThis method is called to notify you that the specified object has been relocated from the range `ostart...oend` to the new range `nstart...nend` of the text. \n\n### onSpanRemoved\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onSpanRemoved(\n text: Spannable!, \n what: Any!, \n start: Int, \n end: Int\n): Unit\n```\n\nThis method is called to notify you that the specified object has been detached from the specified range of the text."]]