我遇到了处理程序的问题。我第一次实例化它时它工作正常。
处理程序位于视图内:
private long delayMillis;
private long mMoveDelay = 1000;
/**
* Create a simple handler that we can use to cause animation to happen. We
* set ourselves as a target and we can use the sleep()
* function to cause an update/invalidate to occur at a later date.
*/
private RefreshHandler mRedrawHandler;
class RefreshHandler extends Handler {
// serve per far vedere tile 2 almeno un tempo prestabilito checkTime
@Override
public void handleMessage(Message msg) {
delayMillis+=mMoveDelay;
System.out.println("--->handleMessage mMoveDelay"+10000);
System.out.println("--->handleMessage delayMillis"+delayMillis);
sleep();
}
public void sleep() {
//this.removeMessages(0);
sendMessageDelayed(obtainMessage(0), mMoveDelay);
System.out.println("--->sleep delayMillis"+delayMillis);
}
};
几次后我跑
mRedrawHandler = new RefreshHandler();
mRedrawHandler.sleep();
sendMessageDelayed 被立即调用。这篇文章中的问题似乎相似:
Handler.sendMessageDelayed(msg, delay) 无法正常工作
你有什么想法吗?谢谢