start Animation on ImageView - Android User Interface

Android examples for User Interface:ImageView

Description

start Animation on ImageView

Demo Code


//package com.java2s;
import android.graphics.drawable.AnimationDrawable;
import android.widget.ImageView;

public class Main {
    public static void startAnimation(ImageView pImageView,
            AnimationDrawable pAnimation, int resId) {
        if (pImageView != null && pAnimation == null) {
            pImageView.setBackgroundResource(resId);
            pAnimation = (AnimationDrawable) pImageView.getBackground();
        }/*from ww w  .  j ava2s .com*/
        if (pAnimation != null && !pAnimation.isRunning()) {
            pAnimation.start();
        }
    }
}

Related Tutorials