2007-11-25
【Android】MapView和其它控件一起显示
关键字: MapView,Android
很多朋友要实现MapView和其它控件一起显示,但android XML里面declare <MapView>就一直报InflateException。。。Inflate。。。打气。。。Exception被爆掉?? 寒~~~
国外达人终于解决此问题,竟然是用<class>来declare,寒~~~android API在干哈?!
main.xml:
然后写个很简单的MapActivity:
结果如图。终于可以自己做相关的Map控件和逻辑了,呵呵!
国外达人终于解决此问题,竟然是用<class>来declare,寒~~~android API在干哈?!
main.xml:
xml 代码
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <view class="com.google.android.maps.MapView"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_weight="1" />
- <EditText android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="输入查询地址"
- android:selectAllOnFocus="true"/>
- </LinearLayout>
然后写个很简单的MapActivity:
java 代码
- public class GeoDemo extends MapActivity {
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.main);
- }
- }
结果如图。终于可以自己做相关的Map控件和逻辑了,呵呵!
评论
anarki
2007-11-27
为啥我的模拟器连不上网呢。。。。
anarki
2007-11-27
必须的吧,好比咱们用ListActivity的时候也必须声明一个ListView
larryzou
2007-11-25
看起来不错啊
custom的view都用declare方式,估计google觉得自己的map只是一个custom的component,而不是像button,text这种common component。以后可能会有其他map component比如yahoo,m$ live的
custom的view都用declare方式,估计google觉得自己的map只是一个custom的component,而不是像button,text这种common component。以后可能会有其他map component比如yahoo,m$ live的
发表评论
提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则
- 浏览: 172255 次
- 性别:

- 来自: 在野

- 详细资料
搜索本博客
我的相册
IMG_0308
共 45 张
共 45 张
最近加入圈子
最新评论
-
Google I/O 大会keynote ...
看完这个视频,觉得跟iphone的效果也有一拼啊,而且android是开放式系统 ...
-- by yangzhihuan -
[转] 神秘诅咒
C&K社在je成立分社了?
-- by reed7 -
[转] 神秘诅咒
这年头,俯卧撑都不保险
-- by larryzou -
HTC Kaiser 编译Android ...
我在想能在pc上装个android么,电脑1开机就是1手机
-- by larryzou -
[转]透露社 - 爆雪将为 ...
三个俯卧撑后,会在听到“我去了”的咆哮声以后,召唤到无比强大的神秘跳水女战神
-- by larryzou






评论排行榜