【发布时间】:2016-06-22 05:53:24
【问题描述】:
我正在尝试将一个片段插入另一个片段,并且我已经成功地做到了这一点,直到我第一次吃午饭主片段,但当我尝试重新加载片段时,应用程序崩溃了,并且我有这个错误:
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>
【问题讨论】:
-
你试过这篇文章中的建议了吗? stackoverflow.com/questions/14083950/…
-
是的,我已经检查过了,但没有用。这里在 xml 中使用片段,所以它不起作用
-
我终于意识到,不要在片段中使用片段。所以我转移到 PlaceAutocomplete Activity 然后解决了我的问题。谢谢大家的支持
标签: android android-fragments android-nested-fragment