java - android - Showing variable changes -


ok - know there has got simple solution life of me can't figure out.

programming basic android activity iterate through 0-99. have textview want display count. happens stays blank until end , shows ending count (99).

not sure if textview right way display or answer is. appreciated. in advance

try using code in oncreate (where number defined field):

textview.post(new runnable() {     @override     public void run() {         number++;         textview.settext("counting: " + number);         if (number < 100) {             textview.postdelayed(this, 50);         }     } }); 

edit: code edited view classes have post , postdelayed, propagates call handler instance have internally.

you need read bit handler class.

warning: code leaks activity time of approximatelly 5 seconds , should not used directly in production code. need remove runnable message queue @ appropriate time (maybe in ondestroy, depends on needs).

view.removecallbacks anti-memory-leak.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -