Android APIs
public class

TextSwitcher

extends ViewSwitcher
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ android.widget.ViewAnimator
           ↳ android.widget.ViewSwitcher
             ↳ android.widget.TextSwitcher

Class Overview

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

Summary

[Expand]
Inherited XML Attributes
From class android.widget.ViewAnimator
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
TextSwitcher(Context context)
Creates a new empty TextSwitcher.
TextSwitcher(Context context, AttributeSet attrs)
Creates a new empty TextSwitcher for the given context and with the specified set attributes.
Public Methods
void addView(View child, int index, ViewGroup.LayoutParams params)
Adds a child view with the specified layout parameters.
void onInitializeAccessibilityEvent(AccessibilityEvent event)
Initializes an AccessibilityEvent with information about this View which is the event source.
void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
Initializes an AccessibilityNodeInfo with information about this view.
void setCurrentText(CharSequence text)
Sets the text of the text view that is currently showing.
void setText(CharSequence text)
Sets the text of the next view and switches to the next view.
[Expand]
Inherited Methods
From class android.widget.ViewSwitcher
From class android.widget.ViewAnimator
From class android.widget.FrameLayout
boolean checkLayoutParams(ViewGroup.LayoutParams p)
void draw(Canvas canvas)
Manually render this view (and all of its children) to the given Canvas.
void drawableStateChanged()
This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.
boolean gatherTransparentRegion(Region region)
This is used by the RootView to perform an optimization when the view hierarchy contains one or several SurfaceView.
FrameLayout.LayoutParams generateDefaultLayoutParams()
Returns a set of layout parameters with a width of MATCH_PARENT, and a height of MATCH_PARENT.
FrameLayout.LayoutParams generateLayoutParams(AttributeSet attrs)
Returns a new set of layout parameters based on the supplied attributes set.
ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
Returns a safe set of layout parameters based on the supplied layout params.
boolean getConsiderGoneChildrenWhenMeasuring()
This method was deprecated in API level 14. This method is deprecated in favor of getMeasureAllChildren(), which was renamed for consistency with setMeasureAllChildren().
Drawable getForeground()
Returns the drawable used as the foreground of this FrameLayout.
int getForegroundGravity()
Describes how the foreground is positioned.
boolean getMeasureAllChildren()
Determines whether all children, or just those in the VISIBLE or INVISIBLE state, are considered when measuring.
void jumpDrawablesToCurrentState()
Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.
void onInitializeAccessibilityEvent(AccessibilityEvent event)
Initializes an AccessibilityEvent with information about this View which is the event source.
void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
Initializes an AccessibilityNodeInfo with information about this view.
void onLayout(boolean changed, int left, int top, int right, int bottom)
Called from layout when this view should assign a size and position to each of its children.
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

void onSizeChanged(int w, int h, int oldw, int oldh)
This is called during layout when the size of this view has changed.
void setForeground(Drawable drawable)
Supply a Drawable that is to be rendered on top of all of the child views in the frame layout.
void setForegroundGravity(int foregroundGravity)
Describes how the foreground is positioned.
void setMeasureAllChildren(boolean measureAll)
Sets whether to consider all children, or just those in the VISIBLE or INVISIBLE state, when measuring.
boolean shouldDelayChildPressedState()
Return true if the pressed state should be delayed for children or descendants of this ViewGroup.
boolean verifyDrawable(Drawable who)
If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying.
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

Public Constructors

public TextSwitcher (Context context)

Added in API level 1

Creates a new empty TextSwitcher.

Parameters
context the application's environment

pu blic TextSwitcher (Context context, AttributeSet attrs)

Added in API level 1

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

Parameters
context the application environment
attrs a collection of attributes

Public Methods

public void addView (View child, int index, ViewGroup.LayoutParams params)

Added in API level 1

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 the child view to add
index the position at which to add the child
params the layout parameters to set on the child
Throws
IllegalArgumentException if child is not an instance of TextView

public void onInitializeAccessibilityEvent (AccessibilityEvent event)

Added in API level 14

Initializes an AccessibilityEvent with information about this View which is the event source. In other words, the source of an accessibility event is the view whose state change triggered firing the event.

Example: Setting the password property of an event in addition to properties set by the super implementation:

 public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
     super.onInitializeAccessibilityEvent(event);
     event.setPassword(true);
 }

If an View.AccessibilityDelegate has been specified via calling setAccessibilityDelegate(AccessibilityDelegate) its onInitializeAccessibilityEvent(View, AccessibilityEvent) is responsible for handling this call.

Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.

Parameters
event The event to initialize.

public void onInitializeAccessibilityNodeInfo (AccessibilityNodeInfo info)

Added in API level 14

Initializes an AccessibilityNodeInfo with information about this view. The base implementation sets:

Subclasses should override this method, call the super implementation, and set additional attributes.

If an View.AccessibilityDelegate has been specified via calling setAccessibilityDelegate(AccessibilityDelegate) its onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfo) is responsible for handling this call.

Parameters
info The instance to initialize.

public void setCurrentText (CharSequence text)

Added in API level 1

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

Parameters
text the new text to display

public void setText (CharSequence text)

Added in API level 1

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 the new text to display