我试图使用Google的Place自动填充(https://developers.google.com/places/android-api/autocomplete)在我的应用中实现片段。但是我从这个片段到另一个片段中导航,然后回来这个片段如何将Google的PlaceAutoCompleteFragment实现为扩展片段的类
Caused by: java.lang.IllegalArgumentException: Binary XML file line #30: Duplicate id 0x7f0f010f, tag null, or parent id 0x7f0f00c0 with another fragment for com.google.android.gms.location.places.ui.PlaceAutocompleteFragment
at android.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2148)
这是Java代码
private PlaceAutocompleteFragment mSearchPAF;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.some_layout, container, false);
mSearchLocationPAF = (PlaceAutocompleteFragment) parentActivity.getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
}
时得到这个错误这是XML文件
<RelativeLayout
android:id="@+id/someRelativeLayout"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="30dp"
android:background="@drawable/some_drawable">
<fragment
android:id="@+id/place_autocomplete_fragment"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
我也有这个相同的java和xml文件中的另一个地图片段,但我设法解决它通过在这篇文章(Duplicate ID, tag null, or parent id with another fragment for com.google.android.gms.maps.MapFragment)中的答案,但我找不到任何解决方案此地方Aut ocomplete片段
给你自己的'PlaceAutoComplete'一个id。 – tahsinRupam
@tahsinRupam你是什么意思?任何例子? –
可能这是因为你在两个不同的'PlaceAutoComplete'片段中使用了相同的id。 – tahsinRupam