当我尝试将我在 Eclipse 中所做的一些旧布局复制到 IntelliJ Idea 中时,布局中的 Google Maps 部分出现问题,并显示错误:-
此处不允许使用 com.google.android.maps.MapView
我已将 Facets 设置为 Android 3.0 Google API,并且 AVD 管理器正在使用 Google API(API 版本 11)。 Java 代码甚至可以识别 MapActivity。
我错过了什么?任何帮助表示赞赏。
最佳答案
我在使用 IntelliJ 11 时遇到了同样的问题,我是这样解决的:
我使用以下代码创建了一个名为“canvasmap.xml”的布局:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="Your Maps API Key goes here"
/>
在我的主要布局中,我是这样使用的:
...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<include android:id="@+id/map" layout="@layout/canvasmap" />
</RelativeLayout>
...
就在我想显示 map 的地方。它工作正常并停止显示错误。
关于android - IntelliJ Idea 中的谷歌地图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5766617/