I am having trouble understanding this java code. I want the image to twinkle a couple of times, with some delay. The image twinkle once and thats it. Can someone give me an explanation would be great!
private void RunAnimations(int[]melodiTakten) {
for (int i = 0; i < 4; i++) {
ImageView markeringspilen = (ImageView) findViewById(R.id.markeringspil);
markeringspilen.setVisibility(View.VISIBLE);
markeringspilen.postDelayed(new Runnable() {
public void run() {
ImageView markeringspilen = (ImageView) findViewById(R.id.markeringspil);
markeringspilen.setVisibility(View.INVISIBLE);
}
}, 2000);
}
If I understand your idea right, your implementation is wrong in that it sets delayed actions to take place all at the same time. You can space them out like this:
This loop sets up eight delayed visibility changes – a group of four pairs of set visible at
4000*ifollowed by set invisible at4000*i+2000.