• Handler初级用法


    分析:

    首先要定义一个Handler mhandler,并实例化:

    在这个里面,要重写public void handleMessage(Message msg)方法,从方法的名字可以看出这个方法是用来处理Message的,它接受从handler发过来的Message,

    然后做出响应的处理。


    Handler有三个作用:

    一、发送(Messageuixiang)消息

    handler.SendMessage(Message msg)

    二、接受消息(并处理消息)

    handlerMessage(Message msg)

    三、清除消息队列

    handler.remove(what)

    Message类:

    在Message对象中,有三个参数,其中what是用来标记线程的,标记之后,把这个线程的msg发送到主线程中去,用handleMessage(Message msg)接受并做出判断,然后做出相应的处理,最后反应到Activity中去,有需要的话,在UI上面做出相应的变化。

    下面这张图是转别人的,画的很具体。

    参考博客:http://qaohao.iteye.com/blog/509145


  • 相关阅读:
    PHP调用WCF提供的方法
    关于git报 warning: LF will be replaced by CRLF in README.md.的警告的解决办法
    vue中引入mui报Uncaught TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them的错误
    微信小程序报Cannot read property 'setData' of undefined的错误
    Vue那些事儿之用visual stuido code编写vue报的错误Elements in iteration expect to have 'v-bind:key' directives.
    关于xampp中无法启动mysql,Attempting to start MySQL service...的解决办法!!
    PHP的环境搭建
    新手PHP连接MySQL数据库出问题(Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES))
    手机号码、获得当前时间,下拉框,填写限制
    团队作业(五):冲刺总结
  • 原文地址:https://www.cnblogs.com/badboy/p/2183720.html
Copyright © 2020-2023  润新知