I run into the problem where i have received some new data in my MainActivity and wish to pass it to a fragment inside a ViewPager. The only solution i can think of right now is to create a new ViewPager Adapter with the new data. like:
adapter = new ViewPagerAdapter(getFragmentManager(), MainActivity.this, bundle);
And in my ViewPager Adapter, i would further pass this bundle towards the fragment:
@Override
public Fragment getItem(int arg0) {
// TODO Auto-generated method stub
switch(arg0){
case 0:
NewBooksFrag newBookFrag = new NewBooksFrag();
newBookFrag.setArguments(b);
return newBookFrag;
The downside of this method is that i have to create a new adapter every time new data comes in. I am just wondering if there is a better method out there.
I have read about the
adapter.notifydatasetchange()
which calls the
getitemposition(Object object)
and then i can implement a interface which updates the object
See here
but the problem with this method is i do not know how to pass the data to the fragment i wish to update.
thanks in advance!