I have a Fragment, let's call it FragmentA. Inside FragmentA, I start an Activity which changes the data I display in FragmentA, and once I finish the Activity I have launched, I return to FragmentA. The problem is, when this happens, FragmentA still displays the old data. So, I tried to replace FragmentA with a new instance of itself in the onResume, but to no avail, because now FragmentA causes the whole viewpager (which it belongs to) to freeze.
Here's my code:
@Override
public void onResume() {
super.onResume();
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.detach(this);
fragmentTransaction.attach(this);
fragmentTransaction.commit();
}
I also tried to replace FragmentA with this code:
@Override
public void onResume() {
FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager().beginTransaction();
FragmentA fragment = FragmentA.newInstance();
fragmentTransaction.replace(ID?, fragment);
fragmentTransaction.commit();
}
but I don't know how to retrieve the "ID?" to use in fragmentTransaction.replace. I'm rather new to Android and I'm still not sure of how to do certain things. Thank you in advance.