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.
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;
}
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