java - Blink circle with thread and handler but impossible to stop it -


i develop application , want make circle blink when click on button. have 8 circle on view , want them blinking separatly. use code :

public void blink(final view id, final int position, final boolean bool) {         final handler handler = new handler();            thread th = new thread(new runnable()         {             @override             public void run() {                 final int timetoblink = 250;                 try {                     thread.sleep(timetoblink);                 } catch (exception e) {                     e.printstacktrace();                 }                 handler.post(new runnable()                 {                     @override                     public void run()                     {                         if (id.getvisibility() == view.visible) {                                 id.setvisibility(view.invisible);                             } else {                                 id.setvisibility(view.visible);                             }                         blink(id,position,true);                     }                 });             }         });         th.setname(integer.tostring(position));         athread.add(th);         th.start(); 

where id id of circle

but can't stop blink th.interupt

anyone can me please ?

thank @jibysthomas fixe problem use this link , made :

final animation animation = new alphaanimation(1, 0);          animation.setduration(250); // duration - half second         animation.setinterpolator(new linearinterpolator());          animation.setrepeatcount(animation.infinite);          animation.setrepeatmode(animation.reverse); 

and call annimation on circle.

thanks lot jibysthomas


Comments