【Android】MapView和其它控件一起显示
16lz
2021-12-04
很多朋友要实现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 五大布局文件
- android APN的打开与关闭
- android EditText 取消自动获取焦点
- Android中图像变换Matrix的原理、代码验证和应用
- RelativieLayout布局中的android:gravity="center"属性
- android 使用代码方式创建自定义progressBar——自定义控件学习(
- 系出名门 Android(安卓)系列文章索引
- Android(安卓)http请求例子、Unicode转UTF-8 java代码收藏
- 【自定义控件系列四】android绘制实战(一)通过Canvas+Path+Paint