EventBus 消息总线
来源:互联网 发布:java -jar -d 编辑:程序博客网 时间:2024/04/30 21:09
//EventBus观察者 在组件之间通信非常简单 只需要事件接受者和发送者
它可以在Activity和Fragment和Intent 它依赖于生命周期 是代码更简单 体积很小 安装量很大
//得用注解
String是传的我们需要的类型 这个是在接收的类中写的
@Subscribepublic void onEventMainThread(String event) { btn.setText(event);}
//需要注册 在onStart()中注册一下
我们通常在onCreate()生命周期中注册
//注册 EventBus.getDefault().register(this);
//反注册在ondestory中反注册
//反注册@Overrideprotected void onDestroy() { super.onDestroy(); EventBus.getDefault().unregister(this);//反注册EventBus}
//发送
EventBus.getDefault().post("chai");
阅读全文
0 0
- EventBus消息总线机制
- EventBus 消息总线
- EventBus 消息总线
- 消息总线——EventBus
- 开源消息总线eventBus学习
- 消息总线重构之EventBus
- 【开源框架】EventBus 消息总线使用
- EventBus事件总线库
- Guava - EventBus(事件总线)
- EventBus--事件总线
- EventBus 3.0 事件总线
- Eventbus 事件总线
- EventBus 事件总线
- 事件总线---EventBus使用
- EventBus事件总线学习
- 事件总线之EventBus
- [Android] EventBus事件总线
- EventBus 事件总线
- getopts 示例2
- HttpURLConnection (get请求)
- jQuery自定义动画函数animate() easing: "easeInOutCirc"导致的animate()动画抖动问题解决方法
- 美团点评会成为阿里巴巴未来最大的竞争对手吗?
- 洞见| 智能引领数字经济 2017 ICT企业家大会带您与产业领袖同行未来!
- EventBus 消息总线
- Angular4学习笔记(三)
- 将String字符串转换为GB2312编码
- s5pv210-Linux驱动之MMC/SD/SDIO区别
- 职场中年人,该如何保持效率和活力的两点建议
- tensorflow 报错 libcusolver.so.8.0: cannot open shared object file: No such file or directory
- mybatis generator 使用文档
- each的用法
- C++中substr函数的用法