0
所以我遵循this指南信(或至少嘗試)。R.java沒有R.id.map的地圖
除了必須導入指南中未指定的一些內容之外,一切都很好,除了我無法解釋的紅色曲線。
在這一行:
GoogleMap map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
有下 「地圖」 在 「R.id.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系統的支持,v4.jar我構建路徑,我已經從谷歌SDK(包括谷歌Play服務)正確下載一切。我也有一個API密鑰。顯然它應該現在工作。
什麼是你的紅色花體說,當你點擊它?你確定你的activity_main.xml佈局文件中有'map'id嗎? – 2013-05-02 22:48:48