1

アプリにGoogleマップを実装しています。

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

}
4

2 に答える 2

0

ビルドターゲット(たとえば、Eclipseの[プロジェクト]>[プロパティ]>[Android])がAndroidSDKの「GoogleAPI」バージョン用であることを確認してください。

于 2013-02-16T14:10:04.957 に答える
0

これを試して:

プロジェクトのプロパティを使用して、プロジェクトのビルド ターゲットが Google API であることを選択します

于 2013-02-16T14:12:12.763 に答える