I want to present 4 images in a loop that repeats indefinitely. For now, just run the images once and the presentation is over

0
package vargas_project.market;

import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.app.Activity;
import android.os.Bundle;


import android.widget.ImageView;


public class MainActivity extends Activity {

AnimatorSet set;

ImageView imageView;
int imageResources[]={R.drawable.rosvil, R.drawable.cool_mart, R.drawable. el_pueblo, R.drawable. peri};
int index=0;

protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity1);
    imageView=(ImageView)findViewById(R.id.imageview);
    set=(AnimatorSet)AnimatorInflater.loadAnimator(MainActivity.this, R.animator.slideshow);
    set.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationCancel(Animator animation) {
            super.onAnimationCancel(animation);
        }
        public void onAnimationEnd(Animator animator){
            // ANIMATE THE NEXT IMAGE

            if (index < imageResources.length) {
                imageView.setImageResource(imageResources[index]);
                index++;
                set.start();

            }

        }

            });
    //  START THE ANIMATION
    set.start();
}

}

    
asked by Eduardo Vargas 03.09.2017 в 19:16
source

0 answers