public final boolean postDelayed(Runnable r, long delayMillis)
看英文文档 没看明白求解释
 Causes the Runnable r to be added to the message queue, to be run
     * after the specified amount of time elapses. 
 (前后的懂,下面这句就悲催了)
     * The runnable will be run on the thread to which this handler
     * is attached.
==========网上说 每 delayMillis 执行一次,  为啥我测试一下 只执行一次?这是为啥?
=========================还有哪位明白人顺便把post 等该方法中的postAtTime等其他方法也解释一下 不胜感激

解决方案 »

  1.   

    postDelayed(Runnable r, long delayMillis)延时delayMillis毫秒 将Runnable插入消息列队,
    Runnable将在handle绑定的线程中运行。post 是立即插入消息列队,当消息列队处理到该消息时才运行
      

  2.   

    个人见解:
    The runnable will be run on the thread to which this handler is attached. 
    这句话的意思是这个接口将会在线程绑定的handler上运行,就是说你的handler绑定哪个线程,就延迟哪个线程
      

  3.   

    The runnable will be run on the thread 
    runnable将会在一个线程中运行什么样的线程的?
    to which this handler is attached即:
    this handler is attached to the thread 
    有handler附属的一个线程,随便翻译的
      

  4.   

    public final boolean postDelayed(Runnable r, long delayMillis)
    从当前时间开始延迟delayMillis时间后执行Runnable,只执行一次
    public final boolean postAtTime(Runnable r,long uptimeMillis)
    在指定的有效时间内执行并且完成Runnable源码在对此方法的返回值有个提醒:
       
    usually because the looper processing the message queue is exiting.    
    Note that a
     result of true does not mean the Runnable will be processed -- if
     the looper is quit before the delivery time of the message
     occurs then the message will be dropped.大概意思是说结果返回true不一定就意味着执行完成了Runnable,比如-如果looper在小于uptimeMillis的时间内退出的话,消息将会被停止
      

  5.   

    LZ查看下 Handle和 Message之间的关系就了解了
    Handler实际上就是个定时器,与Timer差不多,主要维护了一个消息队列MessageQueue
      

  6.   


    该方法,是将runable对象加入消息队列。那肯定是执行一次了。除非你在runable方法体里递归调用了postDelayed方法。后面那个时间是延迟的时间,至于你翻译不懂那句,是指“该runable对象将被执行在handle所在的线程。通常是指UI线程。”