Android
android.widget
public class

android.widget.ViewSwitcher

java.lang.Object
android.view.View Drawable.Callback KeyEvent.Callback
android.view.ViewGroup ViewManager ViewParent
android.widget.FrameLayout
android.widget.ViewAnimator
android.widget.ViewSwitcher

Shows only one child at a time. Will automatically flip between children if you ask. A ViewSwitcher can hold only two children at the same time.

Nested Classes
ViewSwitcher.ViewFactory Creates views in a ViewSwitcher. 
Known Direct Subclasses

Summary

XML Attributes inherited from class android.widget.FrameLayout
XML Attributes inherited from class android.view.ViewGroup
XML Attributes inherited from class android.view.View
Constants inherited from class android.view.ViewGroup
Constants inherited from class android.view.View
Fields inherited from class android.view.ViewGroup
Fields inherited from class android.view.View

Public Constructors

            ViewSwitcher(Context context)
Creates a new empty ViewSwitcher.
            ViewSwitcher(Context context, AttributeSet attrs)
Creates a new empty ViewSwitcher 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.
          View  getNextView()
Returns the next view to be displayed.
          void  reset()
Reset the ViewSwitcher to hide all of the existing views and to make it think that the first time animation has not yet played.
          void  setFactory(ViewSwitcher.ViewFactory factory)
Sets the factory used to create the two views between which the ViewSwitcher will flip.
Methods inherited from class android.widget.ViewAnimator
Methods inherited from class android.widget.FrameLayout
Methods inherited from class android.view.ViewGroup
Methods inherited from class android.view.View
Methods inherited from class java.lang.Object
Methods inherited from interface android.graphics.drawable.Drawable.Callback
Methods inherited from interface android.view.KeyEvent.Callback
Methods inherited from interface android.view.ViewManager
Methods inherited from interface android.view.ViewParent

Details

Public Constructors

public ViewSwitcher(Context context)

Creates a new empty ViewSwitcher.

Parameters

context the application's environment

public ViewSwitcher(Context context, AttributeSet attrs)

Creates a new empty ViewSwitcher 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)

Adds a child view with the specified layout parameters.

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

IllegalStateException if this switcher already contains two children

public View getNextView()

Returns the next view to be displayed.

Returns

  • the view that will be displayed after the next views flip.

public void reset()

Reset the ViewSwitcher to hide all of the existing views and to make it think that the first time animation has not yet played.

public void setFactory(ViewSwitcher.ViewFactory factory)

Sets the factory used to create the two views between which the ViewSwitcher will flip. Instead of using a factory, you can call addView(android.view.View, int, android.view.ViewGroup.LayoutParams) twice.

Parameters

factory the view factory used to generate the switcher's content
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56