I have FragmentA and FragmentB and have a problem with setting the title of my Activity when FragmentA becomes back visible.
Flow
- FragmentA Visible (not added to the backstack)
- add FragmentB (added to the backstack)
- back button pressed, not the default implementation but need to capture it in the Fragment but I do
getActivity().getSupportFragmentManager().popBackStack();
Now When FragmentA is back visible, the title of the Activity must be changed again like, FragmentA title = "A", FragmentB title = "B". But when FragmentA is back visible, the title is still "B" because onResume isn't called in FragmentA. What are my options to always set title to "A" in FragmentA is visible.
Code:
FragmentA
@Override
public void onResume() {
super.onResume();
getActivity().setTitle("POI's");
}
FragmentB
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
...
getActivity().setTitle("POI");
...
}