android - ListView header 中的 SupportMapFragment

标签 android android-maps-v2

我正在使用基于 Fragment 的应用程序,需要使用 Google Maps API v2 来显示 map 。我正在尝试将 SupportMapFragment 放入 ListView header 中,但不确定如何实现。

我已尝试创建 fragment 的 newInstance 并调用 getView 将其设置为 headerView,但 getView 返回 null。

这行不通:

SupportMapFragment s = SupportMapFragment.newInstance();
list.addHeaderView(s.getView());

谢谢。

最佳答案

通过在自己的 xml 文件中定义 fragment 、扩充该 View 并将其添加为标题 View 使其工作。

关于android - ListView header 中的 SupportMapFragment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15429102/

相关文章:

android - iframe 不工作 android inbuild 浏览器如何解决问题?

android - 如何在 Android 日历中设置 eventID

android - 谷歌地图 v2 android api key 仅适用于调试 key

带有 Android-Maps-Extensions 的 Android Maps V2 添加大量标记非常慢

android - 谷歌地图 V2 和 HTC Wildfire S : Outofmemory error

android - 折线未完成到谷歌地图上的目的地

android - 需要帮助修复我的类(class) : 'This Handler class should be static or leaks might occur'

java - Google Play 在使用 Android Studio 后检测到新权限

java - 当我在 fragment 中后按时按钮不可见

java - Google Maps V2 - Android - 获取当前缩放级别