EventBus广播传值(不管在哪个界面传 .在哪个界面接收都可行)
首先下载EventBus.jar包
A 页面得到值
如:public void onEventKeyBorad(String message){
}
2:默认提供的方法EventBus.getDefault().register(this);
实现接收方法:
public void onEventMainThread(int i){
}
B页面需要传值
1:EventBus.getDefault().post(item);
注意:最后需要在onDestory()方法中去注销广播
EventBus.getDefault().unregister(this);// 反注册EventBus
EventBus广播传递机制
本文介绍如何使用EventBus实现在不同界面间传递消息。主要内容包括:A页面注册EventBus并定义接收方法,B页面发送消息,确保在Activity销毁时注销EventBus。
1684

被折叠的 条评论
为什么被折叠?



