2013-02-16 86 views
1

我在我的應用上實施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; 
} 

} 

回答

0

確保您的構建目標(例如,Project> Properties> Andro Eclipse中的id)適用於Android SDK的「Google APIs」版本。

+0

由於作爲千恩萬謝commonWare簡單的谷歌的API。當我能夠時,會將您的答案標記爲正確 – user1352057 2013-02-16 14:13:01

0

試試這個:

您選擇項目建設目標是使用項目屬性