您的位置:首页 > 移动开发 > Android开发

[置顶] 【Android】AndroidStudio关于EventBus报错解决方法its super classes have no public methods with the @Subscribe

2016-09-05 10:34 591 查看
作者:程序员小冰,GitHub主页:https://github.com/QQ986945193

新浪微博:http://weibo.com/mcxiaobing

首先说明,以前我用eventBus的jar包写得项目demo,前几天就写了一个EventBus的实例,这次我没用jar包,直接用gradle引用的,可是demo写完了,报错:

its super classes have no public methods with the @Subscribe annotation

所以就用google搜索了一下,找到了解决方法,那就是在接受者

onEvent()方法添加注解: @Subscribe 然后问题解决,如:

/**
*
* 从发布者那里得到eventbus传送过来的数据
*
* 加上@Subscribe以防报错:its super classes have no public methods with the @Subscribe annotation
*
* @param event
*/
@Subscribe
public void onEvent(String event){
tv.setText(event);
}


效果图如下:



eventBus简单使用实例demo需要的可以直接去下载:

(AndroidStudio版)github下载地址:

https://github.com/QQ986945193/DavidEventBusDemo

(AndroidStudio版)git开源中国下载地址:

http://git.oschina.net/MCXIAOBING/DavidEventBusDemo

(AndroidStudio版)CSDN免积分下载地址:

http://download.csdn.net/detail/qq_21376985/9623446
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐