android - ActionBarSherlock + Google Maps API v2 重复 ID

标签 android google-maps actionbarsherlock google-maps-android-api-2

我正在尝试将 ActionBarSherlock 与 Google Maps API v2 fragment 集成。

我有一个包含 2 个 fragment 的布局:一个用于列表布局,另一个带有 SupportMapFragment。

当我第一次点击一个列表项时一切顺利,但是当我第二次点击一个列表项时,它会抛出一个错误:“Duplicate id 0x7f040038, tag null, or parent id 0x0 with another fragment for com.google.android .gms.maps.SupportMapFragment"

我尝试了多种解决方案,但没有一个能够修复它。我做错了什么吗?请帮助我!!

我修改了 ActionBarSherlock 以包含实现的 SherlockMapFragment 以支持新的 SupportMap(如此处所示:https://gist.github.com/4392030)。

这是我的代码: https://github.com/inigo-jimenez/TestGoogleMaps

最佳答案

这不是 ActionBarSherlock 的问题,而是当您在自定义 fragment 中包含 SupportMapFragment 时的一个更广泛的问题。

您需要使用 getChildFragmentManager() 添加 SupportMapFragment 而不是通过 xml。

在这里看看我的回答:MapFragment in Fragment, alternatives?

关于android - ActionBarSherlock + Google Maps API v2 重复 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14481950/

相关文章:

java - R.styleable无法解析

javascript - 将 VueJS 组件渲染到 Google Map Infowindow

android - 如何为弹出菜单项设置 id,以作为 View id 找到?

java - Android 编程新手,尝试创建导致登录屏幕的登录按钮。当我单击登录按钮时,应用程序显示 "stopped working"

Python 谷歌地图地理编码 API

java - Android ActionBarSherlock 选项卡 : Fragments View

android - ViewPager + Fragments - 未显示 fragment

android - Action 条 Sherlock : can't resolve Menu and MenuItem imports

javascript - 如何在 javascript/jquery 中检查 html5 视频的全屏请求?

javascript - 如何删除谷歌地图上绘制的多边形