Updating The Listview In A Fragment From A Dialog In Fragmentactivity(using A Viewpager)
I have a FragmentActivity (main) which creates 3 Fragments and also a menu. Pretty straight forward, and from the examples in the Android SDK. @Override protected void onCreate(Bun
Solution 1:
Your code doesn't work because the line:
mSectionsPagerAdapter.getItem(2)
doesn't return the Fragment
at position 2 from the ViewPager
, it creates a new Fragment
for that position and calling update methods on this Fragment
instance will obviously not make any changes as this Fragment
isn't attached to your Activity
(is not the visible one).
Try to look for that Fragment
using the FragmentManager
like below and see how it goes:
// ...
Toast.makeText(Main.this, "Maträtt tillagd", Toast.LENGTH_LONG).show();
//FoodListSectionFragment f = (FoodListSectionFragment)Main.this.getSupportFragmentManager().findFragmentByTag("FoodList");//f.updateList();FoodListSectionFragmentfr= getSupportFragmentManager().findFragmentByTag("android:switcher:" + R.id.theIdOfTheViewPager + ":2");
if (fr != null && fr.getView() != null) {
fr.updateList();
}
Post a Comment for "Updating The Listview In A Fragment From A Dialog In Fragmentactivity(using A Viewpager)"