Added in API level 1

TextSwitcher


open class TextSwitcher : ViewSwitcher
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.FrameLayout
   ↳ android.widget.ViewAnimator
   ↳ android.widget.ViewSwitcher
   ↳ android.widget.TextSwitcher

Specialized android.widget.ViewSwitcher that contains only children of type android.widget.TextView. A TextSwitcher is useful to animate a label on screen. Whenever setText(java.lang.CharSequence) is called, TextSwitcher animates the current text out and animates the new text in.

Summary

Inherited XML attributes
Inherited constants
Public constructors
TextSwitcher(context: Context!)

Creates a new empty TextSwitcher.

TextSwitcher(context: Context!, attrs: AttributeSet!)

Creates a new empty TextSwitcher for the given context and with the specified set attributes.

Public methods
open Unit
addView(child: View!, index: Int, params: ViewGroup.LayoutParams!)

Adds a child view with the specified layout parameters.

open CharSequence!

open Unit

Sets the text of the text view that is currently showing.

open Unit

Sets the text of the next view and switches to the next view.

Inherited functions
Inherited properties

Public constructors

TextSwitcher

Added in API level 1
TextSwitcher(context: Context!)

Creates a new empty TextSwitcher.

Parameters
context Context!: the application's environment

TextSwitcher

Added in API level 1
TextSwitcher(
    context: Context!,
    attrs: AttributeSet!)

Creates a new empty TextSwitcher for the given context and with the specified set attributes.

Parameters
context Context!: the application environment
attrs AttributeSet!: a collection of attributes

Public methods

addView

Added in API level 1
open fun addView(
    child: View!,
    index: Int,
    params: ViewGroup.LayoutParams!
): Unit

Adds a child view with the specified layout parameters.

Note: do not invoke this method from draw(android.graphics.Canvas), onDraw(android.graphics.Canvas), dispatchDraw(android.graphics.Canvas) or any related method.

Parameters
child View!: the child view to add
index Int: the position at which to add the child or -1 to add last
params ViewGroup.LayoutParams!: the layout parameters to set on the child
Exceptions
java.lang.IllegalStateException if this switcher already contains two children
java.lang.IllegalArgumentException if child is not an instance of android.widget.TextView

getAccessibilityClassName

Added in API level 23
open fun getAccessibilityClassName(): CharSequence!

setCurrentText

Added in API level 1
open fun setCurrentText(text: CharSequence!): Unit

Sets the text of the text view that is currently showing. This does not perform the animations.

Parameters
text CharSequence!: the new text to display

setText

Added in API level 1
open fun setText(text: CharSequence!): Unit

Sets the text of the next view and switches to the next view. This can be used to animate the old text out and animate the next text in.

Parameters
text CharSequence!: the new text to display