首先說明,以前我用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); }
效果圖如下: