I have a fragment container that holed 3 different fragments and i want to notify message between the 3 fragment
What is the best way to do it?
Thanks
I have a fragment container that holed 3 different fragments and i want to notify message between the 3 fragment
What is the best way to do it?
Thanks
Here you go. this is the right and full way of doing fragment <-> activity communication. fragment <-> fragment communication should passthrough the activity who controls them. I added the relevant interfaces, with onBackPress as an example:
The simplest & best approach will be use of some event bus library. It will keep your code clean & loosely coupled communications between fragments,activities.
Otto is extremely easy to setup & use. It is from sqaure. Check it out at @ http://square.github.io/otto/
http://corner.squareup.com/2012/07/otto.html will also give you glimpse of what problem it solves.
Keeping a common variable in Activity(if small data) or, write an interface in Activity and implement that in all fragments. And using interfaces pass the data, by writing methods in it.