直接晒代码吧:
private count = 0;
private change = false;
import java.util.Timer;
import java.util.TimerTask;
//animation flash effect
private void forwardbtnAnimation(){
count = 0;
change = false;
timer = new Timer();
task = new TimerTask() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
if (count < 10) { //闪烁5次
if (change == true) {
change = false;
forwardbtn.setVisibility(View.VISIBLE);
} else {
change = true;
forwardbtn.setVisibility(View.INVISIBLE);
}
count++;
}
}
});
}
};
timer.schedule(task,0,100); //0表示立即开始,100为每100ms执行一次
}
提示:android控件的都是线程不安全的,因此更新控件必须得放在Runnable()中。
参考:http://blog.csdn.net/mingxunzh/archive/2010/04/17/5497987.aspx
private count = 0;
private change = false;
import java.util.Timer;
import java.util.TimerTask;
//animation flash effect
private void forwardbtnAnimation(){
count = 0;
change = false;
timer = new Timer();
task = new TimerTask() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
if (count < 10) { //闪烁5次
if (change == true) {
change = false;
forwardbtn.setVisibility(View.VISIBLE);
} else {
change = true;
forwardbtn.setVisibility(View.INVISIBLE);
}
count++;
}
}
});
}
};
timer.schedule(task,0,100); //0表示立即开始,100为每100ms执行一次
}
提示:android控件的都是线程不安全的,因此更新控件必须得放在Runnable()中。
参考:http://blog.csdn.net/mingxunzh/archive/2010/04/17/5497987.aspx