ActionBarSherlock + Google Maps API v2 Duplicate Id

别来无恙 提交于 2019-12-30 18:05:29

问题


I'm trying to integrate the ActionBarSherlock with Google Maps API v2 fragments.

I have a layout with 2 fragments: one for a list layout and another with a SupportMapFragment.

When I click on a list item first go well but when I click on a list item second time, it throws an error: " Duplicate id 0x7f040038, tag null, or parent id 0x0 with another fragment for com.google.android.gms.maps.SupportMapFragment"

I tried several solutions and none of them have been able to fix it. Is there something I'm doing wrong? Please help me!!

I modified ActionBarSherlock to include SherlockMapFragment implemented to support the new SupportMap (as shown here: https://gist.github.com/4392030).

This is my code: https://github.com/inigo-jimenez/TestGoogleMaps


回答1:


This is not a problem with ActionBarSherlock, but a broader one when you have SupportMapFragment inside your custom fragment.

You need to use getChildFragmentManager() to add SupportMapFragment and not through xml.

Take a look at my answer here: MapFragment in Fragment, alternatives?




回答2:


Take the id off the Item list fragment in your XML file.

Then put the fragment inside a container layout (LinearLayout). If you need to refer to the fragment go through that layout.

Make sure that you use the onCreateView function instead of the onCreate inside the fragment class.



来源:https://stackoverflow.com/questions/14481950/actionbarsherlock-google-maps-api-v2-duplicate-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!