besides runOnUiThread there is also View#post(Runnable) , which I would prefer here because you do not need ugly references to external activity ( MyActivity.this.runOnUiThread() ).
private class GenerateRunnable implements Runnable { public void run() {
Also do not confuse Runnable and Thread . A Runnable is just a regular class with the run() method. This can be and is often done on the new Thread . If you want, you can also make GenerateThread real Thread as follows:
private class GenerateThread extends Thread { @Override public void run() {
In addition, using the classic Thread , you can also think about using AsyncTask , since this is done specifically for tasks that do something for a long time, and should update the user interface after that or when there is progress.
zapl source share