Reputation: 2860
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
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