java - Changing ImageViews with For Loop in AnimationListener - Android Studio -


i want make animation set of imageviews fade in/out 1 after after user presses button. made array of images (r1, r2, , r3) called list says index "i" has declared final. there way traverse array each imageview animated?

  @override    protected void oncreate(bundle savedinstancestate) {    super.oncreate(savedinstancestate);    setcontentview(r.layout.activity_main);    button = (imagebutton) findviewbyid(r.id.button);    r1 = (imageview) findviewbyid(r.id.r1);    r2 = (imageview) findviewbyid(r.id.r2);    r3 = (imageview) findviewbyid(r.id.r3);    final imageview[] list = {r1, r2, r3};        button.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             button.setvisibility(view.invisible);             animation1 = new alphaanimation(0.0f, 1.0f);             animation1.setduration(1000);             animation1.setstartoffset(2000);                (int = 0; < list.length; i++) {                     animation1.setanimationlistener(new animation.animationlistener() {                     @override                     public void onanimationend(animation arg0) {                                              list[i].startanimation(animation2);                     }                      @override                     public void onanimationrepeat(animation arg0) {                         // todo auto-generated method stub                     }                      @override                     public void onanimationstart(animation arg0) {                         // todo auto-generated method stub                      }                  });                  animation2 = new alphaanimation(1.0f, 0.0f);                 animation2.setduration(1000);                 animation2.setstartoffset(2000);                  animation2.setanimationlistener(new animation.animationlistener() {                      @override                     public void onanimationend(animation arg0) {                         list[i].startanimation(animation1);                     }                      @override                     public void onanimationrepeat(animation arg0) {                         // todo auto-generated method stub                     }                      @override                     public void onanimationstart(animation arg0) {                         // todo auto-generated method stub                      }                  });                  list[i].startanimation(animation1);          }     }); }} 

}


Comments