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