I have a problem here and would like to know if anyone can help me solve this. I have a ViewPager, with 2 fragments, fragment A and fragment B. This viewPager is inside a fragment, we will call FragmentMain. FragmentMain contains a search, I need to send to fragment A and fragment B, which was typed in searchView, then inside fragment A and fragment B, I can "work" with text typed in searchView. Thank you! i was try it's.
Asked
Active
Viewed 162 times
1 Answers
1
There are lot many ways or pattern to pass the data from fragment to fragment, I will list top two ways in the order of preference for cleaner & testable code:
- you can use Otto as a event bus http://square.github.com/otto/
- Define an Interface
UPDATE Otto is officially deprecated, however you can continue using it, As alternative use this

Mani
- 2,599
- 4
- 30
- 49
-
1Don't use Otto, it is deprecated. There is no development happening on it. You can use RxEventBus. Have a look at https://lorentzos.com/rxjava-as-event-bus-the-right-way-10a36bdd49ba – Arun Shankar Aug 01 '17 at 01:39