• Latest Code...

    How to make blink image when click button

    Here is the simple way to make blinking image when click button:

    public class BlinkImage extends Activity {
    private Button btnClick;
    private ImageView imgBlink;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.blink);
    btnClick=(Button)findViewById(R.id.button1);
    imgBlink=(ImageView)findViewById(R.id.imageView1);
    btnClick.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
    // TODO Auto-generated method stub
    blinkblinkImage();
    }
    });

    }
    protected void blinkblinkImage() {

    Animation animation = new AlphaAnimation(1, 0); // Change alpha
        // from fully
        // visible to
        // invisible
        animation.setDuration(500); // duration - half a second
        animation.setInterpolator(new LinearInterpolator()); // do not alter
        // animation
        // rate
        animation.setRepeatCount(Animation.INFINITE); // Repeat animation
        // infinitely
        animation.setRepeatMode(Animation.REVERSE); // Reverse animation at

        imgBlink.startAnimation(animation);

    }
    }


    Sample outputs:




    Happy Coding!!!

    Circle

    Most recent Elastic Search tutorials for beginner, intermediate and advance level developer, Yubraj Pokharel, in CodingWorkspace