I have a ViewPager with two tabs which holds fragment. Inside the first fragment, I have a Gridview which is being populated with Sqlite Db.
I have an custom alertdi
Here is a trick that i use to access Fragments inside a ViewPager in my custom viewPagerAdapter, i add two methods
public class CustomViewPagerAdapter extends FragmentPagerAdapter {
.....
private String getFragmentTag(int viewId, int index) {
return "android:switcher:" + viewId + ":" + index;
}
//mFragManager is a reference to FragmentManager
public Fragment getFragmentByTag(int containerId, int position) {
return mFragManager.findFragmentByTag(getFragmentTag(containerId, position));
}
}
then in your activity or wherever you can access the customViewPager
YourFragment frag = (YourFragment) customViewPager
.getFragmentByTag(YouViewPager.getId(), position);
after that, add a method in YourFragment refreshData (if you like the name!) and in it refresh the grid Hope this help