I got a FragmentPagerAdapter. It\'s getItem
method can return a fragment according to data it has from the outside. After I update the data its suppose to display I
I have faced the similar problem when I was working on my last project. So I found few Solution.
by overriding getItemPosition in the pager adaptor but this is not a good idea.
@Override
public int getItemPosition(Object object) {
// it will recreate all Fragments when
// notifyDataSetChanged is called
return POSITION_NONE;
}
The second one is cabezas Solution.
Most Stable solution override getItemPosition in below fashion:
@Override
public int getItemPosition(Object object) {
if (object instanceof MyFragment) {
// Create a new method notifyUpdate() in your fragment
// it will get call when you invoke
// notifyDatasetChaged();
((MyFragment) object).notifyUpdate();
}
//don't return POSITION_NONE, avoid fragment recreation.
return super.getItemPosition(object);
}