开发者

Whats Wrong with SystemClock.wait()?

I want that my prog wait 1000 ms and change the title of the button... but the prog appears with the chan开发者_运维百科ged 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");




    }
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜