XML (activity_maptest.xml):
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
Java(Maptest.java):
package com.example.app;
import android.app.Activity;
import android.os.Bundle;
public class Maptest extends Activity {
public class MapActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maptest);
}
}
}
显现:
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
.
.
.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<application
android:allowBackup="true"
android:icon="@drawable/icon_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
.
.
.
<activity
android:name="com.example.app.Maptest"
android:label="@string/title_activity_maptest" >
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="MY ACTUAL KEY" />
</application>
当此页面加载到我的页面中时,它只是白色的,并且 LogCat 没有错误。我正在关注谷歌指南:https ://developers.google.com/maps/documentation/android/start ,但似乎我做错了什么?