試試這個:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.splash);
colorr();
}
public void colorr() {
final Handler handler = new Handler();
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
handler.post(new Runnable() {
@Override
public void run() {
button = (Button) findViewById(R.id.button);
if (button.getText().equals("HAI")) {
button.setBackgroundColor(Color.GREEN);
}
colorr1();
}
});
}
}).start();
}
public void colorr1() {
final Handler handler = new Handler();
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
handler.post(new Runnable() {
@Override
public void run() {
button = (Button) findViewById(R.id.button);
if (button.getText().equals("HAI")) {
button.setBackgroundColor(Color.BLUE);
}
colorr();
}
});
}
}).start();
}
}