【Android】MapView和其它控件一起显示
16lz
2021-01-23
很多朋友要实现MapView和其它控件一起显示,但android XML里面declare <MapView>就一直报InflateException。。。Inflate。。。打气。。。Exception被爆掉?? 寒~~~
国外达人终于解决此问题,竟然是用<class>来declare,寒~~~android API在干哈?!
main.xml:
- <?xmlversion="1.0"encoding="utf-8"?>
- <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <viewclass="com.google.android.maps.MapView"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_weight="1"/>
- <EditTextandroid:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="输入查询地址"
- android:selectAllOnFocus="true"/>
- </LinearLayout>
然后写个很简单的MapActivity:
- publicclassGeoDemoextendsMapActivity{
- @Override
- publicvoidonCreate(Bundleicicle){
- super.onCreate(icicle);
- setContentView(R.layout.main);
- }
- }
结果如图。终于可以自己做相关的Map控件和逻辑了,呵呵!
更多相关文章
- android 使用代码方式创建自定义progressBar——自定义控件学习(
- 【自定义控件系列四】android绘制实战(一)通过Canvas+Path+Paint
- Android http请求例子、Unicode转UTF-8 java代码收藏
- Android 控件七 ImageView 控件
- Android SQLite数据库 《第一行代码》
- Android简明开发教程二十四:总结及示例代码下载