Java tutorial
//package com.java2s; import android.graphics.drawable.AnimationDrawable; import android.view.View; public class Main { /** * Start given animation on provided view. */ public static void startAnimation(View view, int animationId) { view.setBackgroundResource(animationId); AnimationDrawable animationDrawable = (AnimationDrawable) view.getBackground(); if (animationDrawable != null) { animationDrawable.start(); } } }