Load animation for the imageview. - Android User Interface

Android examples for User Interface:ImageView

Description

Load animation for the imageview.

Demo Code


//package com.java2s;

import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class Main {
    /**//from  ww w . j a  v a 2 s .c  om
     * Load animation for the imageview.
     * 
     * @param imageView
     *            the image view
     * @param animation
     *            the animation
     * @param animationResource
     *            the animation resource
     */
    public static void loadAnimation(ImageView imageView,
            Animation animation, int animationResource) {
        if (imageView == null)
            return;
        if (animation == null && animationResource != 0)
            animation = AnimationUtils.loadAnimation(
                    imageView.getContext(), animationResource);
        if (animation == null) {
            imageView.setAnimation(null);
            return;
        }

        imageView.startAnimation(animation);
    }
}

Related Tutorials