I am creating a tabbed application using a FragmentPagerAdapter
and android.support.v4.view.ViewPager
. In order to follow best practices and separation of concerns I have separated my app into several different fragments. Each of the fragments has an interaction listener that requires an Activity
to subscribe to. Since I only have one activity in the entire app do I have to make the parent (tabbed navigation) activity implement all the listeners in the entire app? This seems like it would be bad practice and create one large monolithic Activity
class that controls the flow of everything.
I have three fragments inside of another fragment that I use as a home page tab. The home page fragment implements the interfaces of the three sub fragments. The problem is that the home page fragment is not an Activity
so the sub fragments throw an exception on onAttach
.
What am I missing? How can I implement fragment listeners in a tabbed application without making one large and messy Activity
class