I'm new to android programming and I have a simple question. I have a random number, nr and I generate this number of ImageViews in the same location. Now, I want to apply an animation to each of these images, but not in the same time.
Let's say I want the first image to start moving at sec 0, then image2 at sec 2 and so on.
I have the images in an array, imb_items[].
for(int j=0; j<nr;j++){
imb_items[j].startAnimation(translateAnim);
????? how can I put here the delay?
}
I'm trying for a long time to do this, but I just can't do it with handlers or threads...I think I don't get the concept. I would be very thankful if somebody would help me understand and give me a sample code that will work in my specific case.
If I use this
for(int j=0; j<i;j++) {
final int finalJ = j;
new android.os.Handler().postDelayed(
new Runnable() {
public void run() {
imb_items[finalJ].startAnimation(translateAnim);
Log.i("tag", "This'll run 5000 milliseconds later");
}
},
5000 * j
);
}
the problem is that when when the second image starts moving, the first one stops and disappears. I would like all the images to continue their movement.
thank you!
Let's say I want the first image to start moving at sec 0, then image2 at sec 2 and so on.
I have the images in an array, imb_items[].
for(int j=0; j<nr;j++){
imb_items[j].startAnimation(translateAnim);
????? how can I put here the delay?
}
I'm trying for a long time to do this, but I just can't do it with handlers or threads...I think I don't get the concept. I would be very thankful if somebody would help me understand and give me a sample code that will work in my specific case.
If I use this
for(int j=0; j<i;j++) {
final int finalJ = j;
new android.os.Handler().postDelayed(
new Runnable() {
public void run() {
imb_items[finalJ].startAnimation(translateAnim);
Log.i("tag", "This'll run 5000 milliseconds later");
}
},
5000 * j
);
}
the problem is that when when the second image starts moving, the first one stops and disappears. I would like all the images to continue their movement.
thank you!