我尝试为 Google 地图编写一个应用程序。
告诉我,我的错误是什么?
如果你这样写,所有的作品,卡都加载了。
public class TravelMapActivity extends MapActivity {
private MapView mapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.travel_map_activity);
mapView = (MapView)findViewById(R.id.travelMapView);
}
}
如果你创建一个构造函数,我会在这里得到这些错误。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.travel_map_activity);
mapView = new MapView(this, getResources().getString(R.string.google_maps_api_key));
}
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.ai.mi.maptrack/de.ai.mi.maptrack.activities.TravelMapActivity}: java.lang.IllegalStateException: You are only allowed to have a single MapView in a MapActivity
Caused by: java.lang.IllegalStateException: You are only allowed to
have a single MapView in a MapActivity
谢谢