0

내 앱에 탭 호스트가 있습니다. 나는 그것을 클릭하면 그것이 조각 활동을 사용하고 5 개 탭 (단편) 3 탭에서 를 포함하는 버튼이, 원래 조각탭 호스트와 프래그먼트 조합 트랜잭션이 안드로이드에서 에러 expection을 내 보냅니다.

gridView.setOnItemClickListener(new OnItemClickListener() { 
      @Override 
      public void onItemClick(AdapterView<?> parent, View v, 
        int position, long id) { 
       tracker.send(MapBuilder.createEvent("click_button","Gallery","Gallery_select_" + Utility.getLocale(getActivity()),null).build()); 
       Bundle bundle = new Bundle(); 
       bundle.putSerializable("imageObj", images.get(position)); 
       Fragment newFragment = (Fragment) new GalleryDetail(); 
       FragmentTransaction transaction = getFragmentManager().beginTransaction(); 
       newFragment.setArguments(bundle); 
       transaction.replace(R.id.tabcontent, newFragment,"gallery_detail"); 
       transaction.addToBackStack("gallery_detail"); 
       transaction.commit(); 
      } 
     }); 

을 대체하는 또 다른 조각,로 이동합니다

1) 3 탭

2 열) 다음 단계의 단편

3로 이동 버튼을 클릭) 다른 탭의 예를 클릭 : 다음 문제는이 흐름에 일어날 것입니다 첫번째 탭

4)이 때 제 3 탭으로 복귀 (, 그것은 것 대신 첫 번째 수준의 다음 수준 조각)

5)을 눌러 뒤로 버튼

02-19 02:16:46.427: E/AndroidRuntime(27697): java.lang.IllegalStateException: Fragment already added: PhotoGallery{43bc3500 #1 id=0x7f04003b Gallery} 

얼마나 내가 할 수있는 세 번째 탭에서 나가면 첫 번째 레벨을 반환 하시겠습니까? 나는 이것이 문제를 해결할 것이라고 믿는다. 도움을 주셔서 감사합니다

답변

0

replace() 방법을 add()remove() 방법으로 대체 할 수 있습니다. 또는 사용해 볼 수도 있습니다 SupportFragmentManager