MasterGberry
MasterGberry

Reputation: 2860

Append information to TableLayout in Thread

I am trying to figure out how to access the View from a thread in my MainActivity class. I need to be able to append information to the table every 5 seconds as it is gathered. How would I go about doing this when the function is in a Thread()?

Thanks.

Upvotes: 0

Views: 41

Answers (1)

Pragnani
Pragnani

Reputation: 20155

Create a one Hanlder as field and initialize it in onCreate of your activity. And then with that Hanlder access UI Thread. i.e Access Views

Or Simply use

 runOnUiThread(new Runnable() {
            public void run() {
               //code needs to be ran in UI thread)

            }
        });

Upvotes: 1

Related Questions