I am having a problem with displaying the same fragment after changing orientation. I put it in the back and popping back. It jumps to onCreateView, etc., but then it calls onDetach, which causes the wrong fragment to be displayed .. the code looks like this:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {...}
@Override
public void onDetach() {
super.onDetach();
this.getActivity().getFragmentManager().beginTransaction().addToBackStack(null);
}
and basically
if (getFragmentManager().getBackStackEntryCount()>1){
setContentView(R.layout.activity_main);
getFragmentManager().popBackStack();
}
Am I missing something? Thank you for your help in advance.
source
share