1> 예를 들어
(새로운 조각을 추가하는 동안 추가 팝업) 스택에 조각을 유지하십시오 : 개인 스택 fragmentStack = 새로운 스택();
// 스택의 새 프래그먼트와 백 스택의 이전 프래그먼트를 추가하는 코드 FragmentTransaction ft = fragmentManager.beginTransaction(); // 코드
Fragment mFragment = new Fragment(); // you can replace this with your fragment
ft.add(R.id.container, mFragment); // you can also add fragment id so that if you can reuse that fragment if it is memory.
fragmentStack.lastElement().onPause();
ft.hide(fragmentStack.lastElement());
fragmentStack.push(resultListFragment);
ft.commit();
상위에서 보이는 단편을 제거하고 (fragmentStack.size() == 2) // 스택이 '예'의 모든 프래그먼트들이 있는지 확인하기 위해 사용하는 경우, 스택 단편을
다시 재개 onbackbutton 이벤트처럼 뒤로 이벤트로 이동하는 것보다 { FragmentTransaction ft = fragmentManager.beginTransaction(); fragmentStack.lastElement(). onPause(); ft.remove (fragmentStack.pop()); fragmentStack.lastElement(). onResume(); ft.show (fragmentStack.lastElement()); ft.commit(); }
2> OutofMemory 오류에 대한 문제가 조각 라이프 사이클의 onCreate (Bundle) 시스템 콜백 메서드에서 setRetaininstance (true)를 사용하는 것보다 해결되지 않으면 이미 조각난 경우 새 조각을 만들지 않습니다.
파괴시 해제되지 않은 FragmentB에 대한 강력한 참조가 있는지 확인해야합니다. 가능한 경우 모든 사람이 조언을 제공 할 수 있도록 여기에 코드 스 니펫을 공유하십시오. – Robo
죄송합니다. 내 코드를 공유 할 수 없습니다. 여기에 내 흐름 애플 리케이션과 같은 샘플 프로젝트를 만들 : https://github.com/sinhpn92/FragmentStackTest. 내 샘플에는이 문제가 없습니다. 하지만 내 프로젝트에서 나는 위의 문제가있다. 왜 그런지 몰라? 이 문제의 원인이 있습니까? –