Skip to content

Most visited

Recently visited

navigation

ImageSwitcher

public class ImageSwitcher
extends ViewSwitcher

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


ViewSwitcher that switches between two ImageViews when a new image is set on it. The views added to an ImageSwitcher must all be ImageViews.

Summary

Inherited XML attributes

From class android.widget.ViewAnimator
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View

Inherited constants

From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.View

Public constructors

ImageSwitcher(Context context)

Creates a new empty ImageSwitcher.

ImageSwitcher(Context context, AttributeSet attrs)

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

Public methods

CharSequence getAccessibilityClassName()

Return the class name of this object to be used for accessibility purposes.

void setImageDrawable(Drawable drawable)

Sets a new drawable on the ImageSwitcher.

void setImageResource(int resid)

Sets a new image on the ImageSwitcher with the given resource id.

void setImageURI(Uri uri)

Sets a new image on the ImageSwitcher with the given Uri.

Inherited methods

From class android.widget.ViewSwitcher
From class android.widget.ViewAnimator
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.view.ViewParent
From interface android.view.ViewManager
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Public constructors

ImageSwitcher

added in API level 1
ImageSwitcher (Context context)

Creates a new empty ImageSwitcher.

Parameters
context Context: the application's environment

ImageSwitcher

added in API level 1
ImageSwitcher (Context context, 
                AttributeSet attrs)

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

Parameters
context Context: the application environment

attrs AttributeSet: a collection of attributes

Public methods

getAccessibilityClassName

added in API level 23
CharSequence getAccessibilityClassName ()

Return the class name of this object to be used for accessibility purposes. Subclasses should only override this if they are implementing something that should be seen as a completely new class of view when used by accessibility, unrelated to the class it is deriving from. This is used to fill in AccessibilityNodeInfo.setClassName.

Returns
CharSequence

setImageDrawable

added in API level 1
void setImageDrawable (Drawable drawable)

Sets a new drawable on the ImageSwitcher. This will set that drawable on the next ImageView in the switcher and will then switch to that view.

Parameters
drawable Drawable: the drawable to be set or null to clear the content

setImageResource

added in API level 1
void setImageResource (int resid)

Sets a new image on the ImageSwitcher with the given resource id. This will set that image resource on the next ImageView in the switcher and will then switch to that view.

Parameters
resid int: a Drawable resource id

setImageURI

added in API level 1
void setImageURI (Uri uri)

Sets a new image on the ImageSwitcher with the given Uri. This will set that image on the next ImageView in the switcher and will then switch to that view.

Parameters
uri Uri: the Uri of an image

See also:

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)