博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Fragment 增加高德地图的 com.amap.api.maps.SupportMapFragment
阅读量:2393 次
发布时间:2019-05-10

本文共 922 字,大约阅读时间需要 3 分钟。

1> 在 Fragment 增加高德地图的 com.amap.api.maps.SupportMapFragment
直接通过在XML布局文件中添加
<fragment
  android:id ="@+id/roadcondition_map_f"
  android:layout_width ="match_parent"
  android:layout_height ="match_parent"
  class= "com.amap.api.maps.SupportMapFragment" />
调用 getSupportFragmentManager() 返回为空,因此使用代码直接添加
    <1> 在xml增加要显示地图的布局
<FrameLayout
  android:id ="@+id/navigation_map_fl"
  android:layout_width ="match_parent"
  android:layout_height ="match_parent"
  android:layout_marginBottom ="60dp" />
    <2> 代码使用SupportMapFragment填充布局
if (mAMap == null)
  {
  FragmentManager fm = getFragmentManager();
  FragmentTransaction transaction = fm.beginTransaction();
  try
  {
  MapsInitializer. initialize( activity);
  }
  catch (RemoteException e)
  {
  e.printStackTrace();
  }
  SupportMapFragment supportMapFragment = new SupportMapFragment();
  transaction.replace(R.id. navigation_map_fl , supportMapFragment);
  transaction.commit();
  mAMap = supportMapFragment.getMap();
  }

转载地址:http://rngab.baihongyu.com/

你可能感兴趣的文章
树莓派安装中文输入法
查看>>
树莓派(raspberry pi)播发flash 远程登录 视频播放
查看>>
Linux 安装与配置服务器版jre7
查看>>
Perform Two Phase Commits in MongoDB
查看>>
java.rmi.ConnectException: Connection refused to host: 127.0.0.1
查看>>
数据库服务器 Cloudscape
查看>>
JAVA中使用Schema校验XML
查看>>
使用BlazeDS实现Java和Flex通信
查看>>
使用 Apache MINA 开发高性能网络应用程序
查看>>
五分钟学会使用spring-data-cassandra快速实现数据的访问
查看>>
Build self-healing distributed systems with Spring Cloud
查看>>
如何利用Spring Cloud构建起自我修复型分布式系统
查看>>
Java代码实现设置系统时间
查看>>
java -D参数简化加入多个jar
查看>>
用Erlang开发的文档数据库系统CouchDB
查看>>
Apache Commons工具集简介
查看>>
Apache Cayenne—辣椒你吃了吗?
查看>>
云应用开发工具:Spring Cloud 1.0 正式发布
查看>>
[转]在VC中使用智能指针操作Excel
查看>>
关于Linux命令行环境下无线网卡的配置
查看>>