很多朋友要实现MapView和其它控件一起显示,但android XML里面declare <MapView>就一直报InflateException。。。Inflate。。。打气。。。Exception被爆掉?? 寒~~~

国外达人终于解决此问题,竟然是用<class>来declare,寒~~~android API在干哈?!
main.xml:

xml 代码
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical"android:layout_width="fill_parent"
  4. android:layout_height="fill_parent">
  5. <viewclass="com.google.android.maps.MapView"
  6. android:layout_width="fill_parent"
  7. android:layout_height="fill_parent"
  8. android:layout_weight="1"/>
  9. <EditTextandroid:layout_width="fill_parent"
  10. android:layout_height="wrap_content"
  11. android:text="输入查询地址"
  12. android:selectAllOnFocus="true"/>
  13. </LinearLayout>


然后写个很简单的MapActivity:

java 代码
  1. publicclassGeoDemoextendsMapActivity{
  2. @Override
  3. publicvoidonCreate(Bundleicicle){
  4. super.onCreate(icicle);
  5. setContentView(R.layout.main);
  6. }
  7. }


结果如图。终于可以自己做相关的Map控件和逻辑了,呵呵!

更多相关文章

  1. android 使用代码方式创建自定义progressBar——自定义控件学习(
  2. 【自定义控件系列四】android绘制实战(一)通过Canvas+Path+Paint
  3. Android http请求例子、Unicode转UTF-8 java代码收藏
  4. Android 控件七 ImageView 控件
  5. Android SQLite数据库 《第一行代码》
  6. Android简明开发教程二十四:总结及示例代码下载

随机推荐

  1. 阿里巴巴Android开发手册
  2. android IPC 机制
  3. Android学习笔记3
  4. Android的图像处理
  5. Mac android 环境配置
  6. Android(安卓)根文件系统启动过程。
  7. Android源码获取方法
  8. Handler
  9. android 下载网络pdf文件后并显示
  10. Android进程系列第六篇---LowmemoryKille