Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;

import android.widget.TextView;

public class Main {
    static int num = 0;

    public static void SetFlickerAnimation(final TextView v, final String info, final String temp) {
        v.setText(info);
        AlphaAnimation anim = new AlphaAnimation(0, 1);
        anim.setDuration(4000);
        anim.setRepeatCount(Animation.INFINITE);
        // anim1.setRepeatMode(Animation.REVERSE);
        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.setText(info);
                } else {
                    v.setText(temp);
                }
            }

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

            }
        });
        v.startAnimation(anim);

    }
}