无法扩展MapActivity类?

问题描述:

我在我的应用上实施Google地图。无法扩展MapActivity类?

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

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

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

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

} 

确保您的构建目标(例如,Project> Properties> Andro Eclipse中的id)适用于Android SDK的“Google APIs”版本。

+0

由于作为千恩万谢commonWare简单的谷歌的API。当我能够时,会将您的答案标记为正确 – user1352057 2013-02-16 14:13:01

试试这个:

您选择项目建设目标是使用项目属性