注册Basefragment时一定要指明类 不要使用this 使用 BaseFragment。this
ev
compile
'org.greenrobot:eventbus:3.0.0'
1可以写一个空类
public class FirstEvent {
private String mMsg;
public FirstEvent(String msg) {
// TODO Auto-generated constructor stub
mMsg = msg;
}
public String getMsg(){
return mMsg;
}
}
3接收处
//注册EventBus
EventBus.getDefault().register(this);
@Override
protected void onDestroy(){
super.onDestroy();
EventBus.getDefault().unregister(this);
}
接收处(必须手打)
@Subscribe
public void onEventMainThread(FirstEvent event) {
}
发送处
发送消息
4 EventBus.getDefault().post(
new FirstEvent("FirstEvent btn clicked"));