I'm interested in implementing a FloatingActionButton or FAB across a number of fragments. When the fragment changes, the FAB's icon should change and the button should obviously then do something pertaining to that specific fragment, however for a seamless display, the FAB is located within the Main Activity and not per-fragment.
What's the most proper and/or efficient way of doing this?
I can't wrap my head around it.. I've tried to implement listeners in the Fragment, for the click in the Activity, but it's saying the listeners are Cyclical
Thanks
You can get the Floating Action Button in your fragments e.g in onCreate
method of fragment by doing something that
FloatingActionButton fab = (FloatingActionButton)this.getActivity().findViewById(R.id.fab);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With