sendmessagedelayed定时器怎么用
1个回答
2016-08-02
展开全部
设置标记为,发送一次后改变标志位,然后循环不进行,操作完了 还原 标志位 继续.
使用DELAY就不要使用线程:
private Handler myhandler = new Handler(){
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
progress += 5;
if (progress < 100){
Message msg = myhandler.obtainMessage();
msg.what = 1;
myhandler.sendMessageDelayed(msg, 2000);
}
pgbar.setProgress(progress);
break;
}
super.handleMessage(msg);
}
};
使用DELAY就不要使用线程:
private Handler myhandler = new Handler(){
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
progress += 5;
if (progress < 100){
Message msg = myhandler.obtainMessage();
msg.what = 1;
myhandler.sendMessageDelayed(msg, 2000);
}
pgbar.setProgress(progress);
break;
}
super.handleMessage(msg);
}
};
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询