AndroidStudio EventBus报错解决方法its super classes have no public methods with the @Subscribe


首先说明,以前我用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);
    }

效果图如下: 
这里写图片描述


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM