This the ViewFlipper that i applied tp get my carousel effect, i tweaked the animation a bit to make it fit what i want exactly. So yes ViewFlipper is your answer.
AnimationDrawable create an infinite Loop
-
15-01-2022 - |
Question
I am using AnimationDrawable to create a Frame by Frame effect, I want to when the images changes, the circle dot change together, my code create a infinite loop, if I get off While(mframeAnimation.isRunning())
then it just check the value one time and stop.
Question:
So what should I do to create an infinite check, a listener or something like that to change the circle when image changes?
private void selectDot(int arg2) {
// TODO Auto-generated method stub
for(int i=0;i<imageView.length;i++){
if(i==arg2) imageView[i].setImageResource(R.drawable.black_circle);
else imageView[i].setImageResource(R.drawable.gray_circle);
}
}
class Starter implements Runnable {
public void run() {
mframeAnimation.start();
while(mframeAnimation.isRunning()){
// Get the frame of the animation
Drawable currentFrame, checkFrame;
currentFrame = mframeAnimation.getCurrent();
int frameNumber;
// Checks the position of the frame
for (int i = 0; i < mframeAnimation.getNumberOfFrames(); i++) {
checkFrame = mframeAnimation.getFrame(i);
if (checkFrame == currentFrame) {
frameNumber = i;
// Toast.makeText(getActivity(), Integer.toString(frameNumber), Toast.LENGTH_SHORT).show();
selectDot(frameNumber);
break;
}
}
}
}
}
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow