java - How can a button change textView color more than once? -


i'm trying make button changes color of textview white, on second press changes blue, , third press red , on. when try chooses last (red) , won't change again. got ideas how can this? stuck. here's code:

 protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     getwindow().addflags(windowmanager.layoutparams.flag_keep_screen_on);     setcontentview(r.layout.activity_main);     dc1 = (textview)findviewbyid(r.id.digitalclock1);     bt1 = (button)findviewbyid(r.id.button1);      handler handler = new randommovehandler((textview) findviewbyid(r.id.digitalclock1));     handler.sendemptymessage(0);      bt1.setonclicklistener(new view.onclicklistener() {          @override         public void onclick(view v) {             // todo auto-generated method stub             dc1.settextcolor(color.white);             dc1.settextcolor(color.blue);             dc1.settextcolor(color.red);         }     });  } 

int[] colors = {color.white, color.blue, color.red };    bt1.setonclicklistener(new view.onclicklistener() {          @override         public void onclick(view v) {              integer tag = (v.gettag() == null) ? 0 : (integer)v.gettag();             int color = colors[tag];             dc1.settextcolor(color);             v.settag((tag+1)%colors.length);         }     }); 

i cannot try now. check typo


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -