android 关于Handler终止问题
privateHandlermHandler=newHandler(){publicvoidhandleMessage(android.os.Messagemsg){fl...
private Handler mHandler = new Handler() {
public void handleMessage(android.os.Message msg) {
float progress = hp.getCurrentCount();
if(stop>progress){
hp.setCurrentCount(++progress);
}
else if(stop<progress){
hp.setCurrentCount(--progress);
}
else{
++error;
}
if (progress >= stop) {
mHandler.removeMessages(MSG_PROGRESS_UPDATE);
}
mHandler.sendEmptyMessageDelayed(MSG_PROGRESS_UPDATE, 30);
};
};
我activity里运行了这个Handler
到达了progress >= stop条件后 运行了 mHandler.removeMessages(MSG_PROGRESS_UPDATE);
可是为什么终止不掉? 展开
public void handleMessage(android.os.Message msg) {
float progress = hp.getCurrentCount();
if(stop>progress){
hp.setCurrentCount(++progress);
}
else if(stop<progress){
hp.setCurrentCount(--progress);
}
else{
++error;
}
if (progress >= stop) {
mHandler.removeMessages(MSG_PROGRESS_UPDATE);
}
mHandler.sendEmptyMessageDelayed(MSG_PROGRESS_UPDATE, 30);
};
};
我activity里运行了这个Handler
到达了progress >= stop条件后 运行了 mHandler.removeMessages(MSG_PROGRESS_UPDATE);
可是为什么终止不掉? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询