I’ve got a multi-Fragment ABS fragment activity with tabs and a ViewPager working pretty well, but for the actual functionality of my application, I need to be able to get hold of the fragments and communicate with them. In order to be able to call findFragmentById(), the fragments need IDs, which (if I understand correctly) requires that they either have a <fragment> tag or be created by a FragmentTransaction. The TabsAdapter/ViewPager code I’m using creates the fragments from a Fragment class using Fragment.instantiate(), which doesn’t allow for setting an ID.
So, any ideas for how to use a tag with a ViewPager, or use a FragmentTransaction to create the tab fragments? I could implement my own id/fragment mapping within my TabsAdapter pretty easily, but I’d rather use a standard mechanism if I can.
FragmentPagerAdapter tags all of the Fragment-tabs it contains using a private method called makeFragmentName.
This is a fragile solution, but will work as of ABS 4.0.2. You’ll need to know the position index of the Fragment you’re looking for
Honestly, you should just use your own, less-fragile solution. At least then you’ll be in control of when/how it breaks.