Saturday, February 7, 2015

Update UI from background thread


private void setText(final TextView text,final String value){
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                text.setText(value);
            }
        });
    }

If you try to update the UI from the background thread directly, this exception occurs:

Only the original thread that created a view hierarchy can touch its views



No comments:

Post a Comment