I have one activity that comprises of three fragments. The fragments use the actionbar tabs using a PagerAdapter. What I want to do is access a method in the active tabbed fragment from the main activity. I have tried the below code but this just returns the fragment as null, so I guess it cant find it within the tabs!
NPListFragment articleFrag = (NPListFragment) getSupportFragmentManager().findFragmentByTag("NP");
articleFrag.refreshT();
PagerAdapter:
public class AppSectionsPagerAdapter extends FragmentPagerAdapter {
public AppSectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int i) {
switch (i) {
case 0:
return new NPListFragment();
case 1:
return new PListFragment();
case 2:
return new FavouritesFragment();
}
return null;
}
@Override
public int getCount() {
return 3;
}
} Can anyone advise? I have spent about 6 hours on this, i'm just not making any progress resolving this.