Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;

import android.widget.ImageView;

public class Main {
    static int num = 0;

    public static void SetMenuAnimation(final ImageView v, final int bg1, final int bg2) {
        v.setImageResource(bg1);
        AlphaAnimation anim = new AlphaAnimation(0.8f, 1);
        anim.setDuration(1000);
        anim.setRepeatCount(Animation.INFINITE);
        // anim1.setRepeatMode(Animation.REVERSE);
        anim.setInterpolator(new AccelerateInterpolator());
        anim.setAnimationListener(new AnimationListener() {
            @Override
            public void onAnimationStart(Animation arg0) {
                // TODO Auto-generated method stub
            }

            @Override
            public void onAnimationRepeat(Animation arg0) {
                // TODO Auto-generated method stub
                num++;
                if (num == 10) {
                    num = 0;
                }
                if (num % 2 == 0) {
                    v.setImageResource(bg1);
                } else {
                    v.setImageResource(bg2);
                }
            }

            @Override
            public void onAnimationEnd(Animation arg0) {
                // TODO Auto-generated method stub

            }
        });
        v.startAnimation(anim);

    }
}