There are two methods. The main one is initializeGame ():
public void initializeGame() { new Thread(new onePoint()).start(); try { Thread.sleep(6000); } catch (InterruptedException e) { e.printStackTrace(); } } } You can see that it launches a new stream, described in the onePoint class:
class onePoint implements Runnable { (...) public void run() { (...) while (...) { try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } (...) if (...) { setOpacityOnButton(...); } } } So here. The initializeGame method starts by pressing the start button. The additional flow is created, the mechanical work with the variables in this additional flow is normal. However, the graphical representation does not change (I call this change by calling the setOpacityOnButton () method) until the main thread ends (that is, it takes about 6 seconds). Why it happens? Certainly not because of if (checked). Just in case this is the setOpacityOnButton () method:
void setOpacityOnButton(int id, final int opacity) { final Button btn = (Button) findViewById(id); runOnUiThread(new Runnable() { @Override public void run() { if (opacity != 0) { btn.setText(Integer.toString(opacity)); } else { btn.setText(""); } } }); }
initializeGame()? It seems to me that you callThread.sleep()directly in the UI thread, and then you try to change the text on the button in it. - zRrr