下面的代码用于闪烁按钮:
public void blink() {
new Thread(new Runnable() {
public void run() {
while (true) {
int timeToBlink = 500;
try { Thread.sleep(timeToBlink); }
catch (Exception e) {}
runOnUiThread(new Runnable() {
@Override
public void run() {
if (btn.getVisibility() == View.VISIBLE) {
btn.setVisibility(View.INVISIBLE);
} else {
btn.setVisibility(View.VISIBLE);
}
}
});
}
}
}).start();
}