[Solved] Change text after a while on Activity start


For the purpose of app responsiveness, as stated in the official documentation on Processes and Threads, it is not recommended to block the UI-thread (for example by calling Thread.sleep()) longer than a few seconds. As also described in the article provided there are several options to avoid that, one of which is to use Handler.postDelayed(Runnable, int) method with the timeout indicating when the new text should show up:

private static final int TIME_OUT = 1000; // [ms]
private TextView tv;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    tv = (TextView) findViewById(R.id.yourTextViewId);
    tv.setText("This is the text to appear when Activity starts up");

    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {

            tv.setText("New text to be shown after TIME_OUT");

        }
    }, TIME_OUT);
}

0

solved Change text after a while on Activity start