evenbus的简单使用方法
来源:互联网 发布:大数据 算法 编辑:程序博客网 时间:2024/05/23 02:04
EvenBus的订阅者和发送者
发送者–(发送)–>订阅者
在gradle中填写依赖
compile 'org.greenrobot:eventbus:3.0.0'
1.在需要接收信息的Activity中注册EvenBus
EventBus.getDefault().register(this);
2.在需要接收信息Activity的public方法上申明@Subscribe
//接收发送来的String类型数据 @Subscribe public void setCurrentTime1(String dataTime) { currentTime.setText(dataTime); } //接收发送来的Date类型数据 @Subscribe public void setCurrentTime2(Date dataTime) { currentTime.setText(dataTime); }
3.在发送信息的地方注册发送信息
//发送String类型数据String a = "2017/11/9";EventBus.getDefault().post(a); //发送Date类型数据SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date curDate = new Date(System.currentTimeMillis()); EventBus.getDefault().post();
注意:发送者发送什么样的参数,在接收函数参数一致时,会接收,不一致时不接收。
阅读全文
0 0
- evenbus的简单使用方法
- EvenBus使用方法
- EvenBus简单使用
- Evenbus个人的一点小见解及简单用法
- EvenBus的入门
- evenbus
- EvenBus
- EvenBus
- EvenBus的使用,(详解)
- __doPostBack简单的使用方法
- MemCache简单的使用方法
- BART 的简单使用方法!
- DetailsView简单的使用方法!
- SimpleCursorAdapter的简单使用方法
- JsonCpp的简单使用方法
- MemCache简单的使用方法
- 简单的list使用方法
- DialogFragment简单的使用方法
- 七、输入输出系统:用锁实现输出、编写键盘驱动程序、环形输入缓冲区
- 让你轻松处理java异常
- 实现APP中轮播图的展示
- Microsoft Office
- MyBatis 通用 Mapper 实现原理
- evenbus的简单使用方法
- kubernetes-dashboard
- getDeclaredMethod和getMethod的区别
- mariadb事务级别
- VMware虚拟机运行时报The CPU has been disabled by the guest operating system错误的解决方法
- 关于指针,我想说
- 洛谷P2871 [USACO07DEC]手链Charm Bracelet
- 极简keras:实现神经网络风格迁移(neural style)
- RecyclerView LinearLayout 显示图片