tags:

views:

49

answers:

1

Hy I want that my prog wait 1000 ms and change the title of the button... but the prog appears with the changed name

package com.catchthebutton;

import android.app.Activity;
import android.os.Bundle;
import android.os.SystemClock;
import android.widget.Button;


public class test extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);

        Button bt = new Button(this);
        setContentView(bt);
        bt.setText("Wait");

        SystemClock.sleep(10000);
        bt.setText("OK");




    }
}
+3  A: 

You should not sleep in the main UI thread. This causes the UI to stop updating until after the sleep is completed.

Instead, look into scheduling an event to occur at a later time using a different thread. See updating the ui for a timer for details.

Mayra
is a easier way possible?
Hans Wurst
Not really. `Handler`s are already pretty simple.
Christopher