林目前在访问Hello Mapview时遇到了一些麻烦,http://developer.android.com/training/tutorials/views/hello-mapview.html,但我认为我做到了这一点。我想在单独的活动中显示地图。谷歌地图在单独的活动导致:java.lang.IllegalStateException:无法执行活动的方法
Map.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="working key"
/>
</LinearLayout>
按钮onclick事件应该显示我的地图
public void showMap(View v){
Intent intent = new Intent(getBaseContext(), GoogleMapsActivity.class);
startActivity(intent);
}
GoogleMapsActivity.java
public class GoogleMapsActivity extends MapActivity
{
MapView mapView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}
该活动已添加到我的清单中,Google apis包含在其中。如果我将地图放在我的主要活动中,但不在我的GoogleMapsActivity
中,则其工作正常。请告诉我在这里错过了什么。
感谢
您已经在这里把整个代码? – Sajmon
@ hawaii.five-0我认为相关的部分。你想看看别的吗? – Johan
哪里例外?在哪一行? – Ran