2016-06-02 4 views
0

일부 데이터를 표시하는 자식 Fragment이 포함 된 부모 Fragment이 있습니다.ChildFragmentManager 제거가 예상대로 작동하지 않습니다.

어떤 시점에서 Child Fragment는 사용자가 완료되었음을 표시합니다 (표시 할 데이터가 없음). 이 시점에서 나는 쓸모없는 조각을 제거하고 싶지만 어떻게 든 성공하지는 못합니다. 내가 놓친 게 있니?

내가 컨테이너에 조각을 추가 (그리고 정말 좋은 작품) 방법 :

if (swipeFragment == null) 
    swipeFragment = new SwipeViewFragment(); 
if (getActivity() != null) { 
    getChildFragmentManager().beginTransaction().add(R.id.jobSearchContainer, swipeFragment, "swipe").commitAllowingStateLoss(); 
    status = SWIPE; 
} 

내가 에 계획이었습니다 그것을 사용하는 방법은 (그러나 그것을 작동하지 않습니다을 제거 시도한 모든 유사 콘텐츠입니다.) :

Fragment swipe = getChildFragmentManager().findFragmentByTag("swipe"); 
if (swipe == null){ 
    throw new RuntimeException("Nope"); 
} 
getChildFragmentManager().beginTransaction().remove(swipe).commit(); 
getChildFragmentManager().beginTransaction().hide(swipe).commit(); 
getChildFragmentManager().popBackStack(); 
getFragmentManager().beginTransaction().remove(swipe).commit(); 

내가 누락 되었습니까?

감사

PS : 나는 그것이 작동하지 않는 것을 말할 때 : 내 말은 조각을 제거하기되지 않고 나는 로그 캣

UPDATE

Fragment swipe = getChildFragmentManager().findFragmentByTag("swipe"); 
    if (swipe == null){ 
     throw new RuntimeException("Nope"); 
    } 
    Log.d("DEBUG", ""+getChildFragmentManager().getFragments().size()); 
    getChildFragmentManager().beginTransaction().remove(swipe).commit(); 
    getChildFragmentManager().popBackStack(); 
    Log.d("DEBUG", ""+getChildFragmentManager().getFragments().size()); 

에는 출력이 없습니다 결과가있다 :

1 
1 
+0

정확히 작동하지 않는 기능은 무엇입니까? 런타임 예외가 발생합니까? 또는 조각이 제거되지 않았습니다 ..? logcat에 어떤 정보가 있습니까? – yennsarah

+0

@Amy 죄송합니다. 조각이 삭제되지 않았으며 로그캣에 정보가 없습니다./충돌이 있습니다. 자동으로 실패합니다 ... –

+0

당신은 backstack에 fragmentTransaction을 추가하지 않으므로, 어떤 결과를 가져올 지 생각하지 않습니다. 디버깅을 시도 했습니까? 'swipe' 조각에 브레이크 포인트를 설정하고 그것이 숨겨져 있는지, 두 번 팽창되었는지 등을 확인하십시오. – yennsarah

답변