yif leo
yif leo

Reputation: 21

View.post() method

I don't understand how to use View.post() method and when to use it like below, I just know it runs in UIThread, so why should I use it?

swipeRefreshLayout.post(newRunnable() {
    @Override
    public void run() {
        swipeRefreshLayout.setRefreshing(true);
    }
}

Upvotes: 1

Views: 2363

Answers (1)

Chandrakanth
Chandrakanth

Reputation: 3831

When your in a worker thread/ separate thread (other than UI thread) at that time if you access the UI elements like buttons or views it will throw exception. So in this situation to update UI elements we have to use View.post() method

Upvotes: 2

Related Questions