Android- Updating UI elements with threading -


i have textview want change thread , again , again (like digital clock). i'm having problems setting time between 2 changes. here, code:

display1 = (textview) findviewbyid(r.id.textview1);  thread timer2 = new thread(){         @override         public void run() {             synchronized (this){                  runonuithread(new runnable() {                     @override                     public void run() {                         int = 0;                         display1.settext("" + i);                         try {                             sleep(2000);                         } catch (interruptedexception e) {                             e.printstacktrace();                         }                         display1.settext("" + (i+1));                     }                 });             }         }     };      timer2.start(); 

this sleep(2000); function makes textview invisible given time want stand still till next change. how can that?

but i'm having problems setting time between 2 changes

do not sleep() on ui thread. if want chain actions delay, split code 2 runnables , first 1 should set display1 , post second runnable delay using postdelayed()

edit

want 1 of them increase 3 per sec, , other 5 per sec until reach 1000 instance

you can make runnable post until criteria met (i.e. time, counter value etc). @ end runnable check conditions , if not met, call postdelayed(this, delay); , good.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -