2016-06-22 1 views
2

다른 프래그먼트를 삽입하려고합니다. 처음이 일하고하지만 난 조각에게 응용 프로그램 충돌을 다시로드려고 할 때, 나는이 오류가 : 이것은 내 조각이다이진 XML 파일 라인 # 26 : ID, 태그 null 또는 상위 ID를 다른 프래그먼트와 중복합니다.

Caused by: java.lang.IllegalArgumentException: Binary XML file line #26: 
Duplicate id 0x7f0e00e2, tag null, or parent id 0xffffffff with another 
fragment for com.google.android.gms.location.places.ui.PlaceAutocompleteFragment 

것은

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
Bundle savedInstanceState) { 

View rootView = inflater.inflate(R.layout.source_destination,container, false); 
PlaceAutocompleteFragment sourcr_autocompleteFragment = (PlaceAutocompleteFragment) 
      getActivity().getFragmentManager() 
.findFragmentById(R.id.sourcr_autocomplete_fragment); 
return rootView; 

// List item 

} 

이 내 XML

입니다
<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" 
     android:padding="10dp" 
     android:background="@color/colorPrimary" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <android.support.v7.widget.CardView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="@dimen/margin_medium" 
      android:layout_marginBottom="@dimen/margin_medium"> 

      <fragment 
       android:id="@+id/sourcr_autocomplete_fragment"  
       android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"   
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 

     </android.support.v7.widget.CardView> 
    </LinearLayout> 
+0

이 게시물에서 제안한 내용을 시도해 보셨습니까? http://stackoverflow.com/questions/14083950/duplicate-id-tag-null-or-parent-id-with-another-fragment-for-com-google-androi?answertab=votes#tab-top – Dus

+0

예 , 이미 그것을 확인하지만, 아무 use.here는 XML에서 조각을 사용하고 있으므로 작동하지 않습니다 – Rgv

+0

마침내 내가 조각에 조각을 사용하지 마십시오. 그래서 PlaceAutocomplete 활동으로 이동 한 다음 내 문제를 해결했습니다. 모든 지원을 감사합니다. – Rgv

답변

3

오버라이드 (override)하는 난 그냥 같은 문제로 실행하고 onDismiss 콜백에서 조각을 제거하여 그것을 해결할 수있는 단편

public void onDestroyView() { 
    super.onDestroyView(); 
    FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); 
    Fragment fragment = fragmentManager.findFragmentById(R.id.sourcr_autocomplete_fragment); 
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); 
    fragmentTransaction.remove(fragment); 
    fragmentTransaction.commit(); 
} 
+0

응답 주셔서 감사합니다, 나는 이미 시도했지만 행운 같은 오류가 점점 – Rgv

3

에서 onDestroyView 방법.

@Override 
public void onDismiss(DialogInterface dialog) { 
    super.onDismiss(dialog); 

    if (getActivity() != null) { 
     FragmentManager fragmentManager = getActivity().getFragmentManager(); 
     Fragment fragment = fragmentManager.findFragmentById(R.id.sourcr_autocomplete_fragment); 
     FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); 
     fragmentTransaction.remove(fragment); 
     fragmentTransaction.commit(); 
    } 
}