订阅类有没有公共方法呼吁事件 [英] Subscriber class has no public methods called on Event

查看:1857
本文介绍了订阅类有没有公共方法呼吁事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用绿色机器人Eventbus我得到了一个错误

while using green Robot Eventbus I got an error

 E/AndroidRuntime(2537): Caused by: de.greenrobot.event.EventBusException: Subscriber class com.example.MyActivity has no public methods called onEvent

详细内容:

我加载其中包含一个片段用10子的片段,而不是调用 EventBus.getDefault()活动报名(本); 在每一个嵌套的(子)片段我打电话了在片段的父活动寄存器

I'm loading Activity which contains a fragment with 10 child fragments, rather than calling EventBus.getDefault().register(this); in every nested (child) fragment I called that register in a parent activity of that fragment.

推荐答案

通过声明 onEventMainThread 解决方法和 EventBus.getDefault()。寄存器(本); 在同一个片段(应当同一个类中声明)

Solved by declaring the onEventMainThread method and EventBus.getDefault().register(this); in a same fragment (should be declared in same class)

这篇关于订阅类有没有公共方法呼吁事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆