Reputation: 5975
I have used the tabbed activity template provided by android studio but i can't happen to find the id for the different fragments used. the template had only one .xml and .java for all three fragments. I made a few changes and made three separate .xml and .java for the three fragments. But I can't figure out how to set the id for the different fragments either from .xml or in .java and without the id I can't perform inter fragment communication.
Upvotes: 4
Views: 602
Reputation: 3045
Now for retrieving a fragment
Fragment f = getSupportFragmentManager().findFragmentByTag(getFragmentTag(mViewPager.getId(), mViewPager.getCurrentItem()));
public static String getFragmentTag(int viewId, long id) {
return "android:switcher:" + viewId + ":" + id;
}
Upvotes: 1