I have three fragments in a viewpager set up like a sliding tab layout. I need to pass a string value from one fragment to another.
First, I tried setting up an interface like the answers here suggest How to pass data between fragments which did not work for me. The idea is that Fragment A tells the Main Activity and then the Main Activity tells Fragment B.
So I looked for different answers
http://android-er.blogspot.com/2012/06/communication-between-fragments-in.html
Looked promising but didn't work because I couldn't use the same functions with my code since I set up my viewpager with google's slidingtablayout instead of the old actionbar.
Now I've stumbled upon EventBus. And I really think this is my answer. I added it to my code just as both below answers suggest. Nothing crashes, but nothing works either.
I find this in the logcat:
D/Event: No subscribers registered for event class tk.abestudying.atob.TextChangedEvent D/Event: No subscribers registered for event class de.greenrobot.event.NoSubscriberEvent
Communication between Fragments in ViewPager
Communication between SlidingTabLayout tabs
Here is my code: Link removed
Please help. I have been trying out solutions for hours, but I am stumped. Thank you.
Edit: I got it working by being cautious and rewriting code.
Looks like you're missing the @Subscribe
annotation. According to the README
, a subscribing method should look like this:
@Subscribe
public void onEvent(AnyEventType event) {/* Do something */};