-1

I have a linear layout in which I am placing a textview with the id "out". In my code i am getting this textview and calling out.append("Some string here");. What i want to do is have it use a thread.sleep(1000); to wait one second and then do another append. When i just use a for loop and iterate through it ten times it waits ten seconds and then updates the view at the end. How can i make this update the view in between the sleeps?

ps. The main reason for this is because i have another thread running with a bluetooth output stream and i want it to update the textview every time i send a byte to an arduino connected through a bluesmirf module. I can get it to send data but the updating of the screen happens at the end of the for loop. If i put a sleep in this loop it will wait the one second and then output to the arduino no problem. I just want to update it so i can see where things fail as they fail without using the logs.

user1571959
  • 23
  • 1
  • 4

1 Answers1

1

Maybe you can use a postdelay handler

Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    public void run() {
                   //Here is the code you want to run after 1 second
                    }
                }, 1000);

The handler is not blocking, but maybe it can help

Excuse me for my bad english, good luck!

SolArabehety
  • 8,467
  • 5
  • 38
  • 42