无法扩展MapActivity类?

时间:2013-02-16 14:08:27

标签: java android api google-maps

我正在我的应用上实施Google地图。

我已经获得了我的API密钥等,目前正在关注一些教程。我需要扩展MapActivity超类,但我目前无法这样做。

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

但仍然接受'MapActivity无法解析为类型'错误。 Heres是我的清单:

<?xml version="1.0" encoding="utf-8"?>

<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:

 <?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>

我的班级:

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;
}

}

2 个答案:

答案 0 :(得分:0)

确保您的构建目标(例如,项目&gt;属性&gt; Android中的Android)适用于Android SDK的“Google API”版本。

答案 1 :(得分:0)

试试这个:

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

相关问题