0

I'm trying to pause a thread briefly while I show a message, but when I try to run the application, it doesn't run the code preceding the sleep until AFTER the sleep is complete (or at least doesn't update the UI).

public void toPause(View view) {
    TextView textView = (TextView) findViewById(R.id.my_textView);
    textView.setText("Waiting...");

    SystemClock.sleep(500);

    textView.setText("Finished.");
}

Is there any way to update the UI in conjunction with sleep()? Or will I have to use a handler? Thanks.

Edit: I have also tried separating it into separate functions.

4

0 回答 0