首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法扩展MapActivity类?

无法扩展MapActivity类?
EN

Stack Overflow用户
提问于 2013-02-16 22:08:27
回答 2查看 491关注 0票数 1

我正在我的应用程序上实现谷歌地图。

我已经获得了我的API密钥等,目前正在遵循一系列的教程。我需要扩展MapActivity超类,但目前还不能这样做。

我已经在清单中实现了地图库,并在XML布局中插入了API密钥。

但仍然收到“无法将MapActivity解析为类型”错误。以下是我的清单:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>

代码语言:javascript
复制
<uses-sdk android:minSdkVersion="8" />

<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".MainMap"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
  <uses-library android:name="com.google.android.maps" />
</application>
</manifest>

这是我的XML:

代码语言:javascript
复制
 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent">

<com.google.android.maps.MapView 
    android:id="@+id/mapView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:enabled="true"
    android:clickable="true"
    android:apiKey="AIzaSyCJSfjl_7lU7-HKV3yIf5nnMODl6qiG2_g"
    />

 </RelativeLayout>

还有我的班级:

代码语言:javascript
复制
package com.example.map;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainMap extends MapActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maplayout);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.maplayout, menu);
    return true;
}

}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-02-16 22:10:05

确保您的构建目标(例如,Eclipse中的Project > Properties > Android )是针对Android SDK的"Google API“版本。

票数 0
EN

Stack Overflow用户

发布于 2013-02-16 22:12:13

试试这个:

使用项目属性选择项目构建目标是Google API

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14911153

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档