【发布时间】:2013-05-02 22:45:44
【问题描述】:
所以我正在关注this 信中指南(或至少尝试这样做)。
除了必须导入一些未在指南中指定的东西外,一切都很好,除了有一个我无法解释的红色曲线。
在这一行:
GoogleMap map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
“R.id.map”中“map”下方有一个红色标记。
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.*;
import android.os.Bundle;
import android.app.Activity;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class MainActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GoogleMap map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
我已经将 android-support-v4.jar 包含在我的构建路径中,并且我已经从 Google SDK(包括 Google Play 服务)正确下载了所有内容。我也有一个 API 密钥。显然它现在应该可以工作了。
【问题讨论】:
-
当您点击红色曲线时,它会显示什么?你确定你的activity_main.xml布局文件中有'map' id吗?
标签: java android eclipse google-maps google-api