我正在使用一个名为ExtendedMapView的扩展MapView类,它将沿着MapView包含currentLocation。然而,这个班级会导致卡车崩溃。
这是MapActivity类的一部分,它导致了粉碎:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
map=(ExtendedMapView)findViewById(R.id.map_view);}
ExtendedMapView类:
package com.sit.augmented_reality.map;
import android.content.Context;
import android.location.Location;
import com.google.android.maps.MapView;
public class ExtendedMapView extends MapView {
private Location currentLocation;
public ExtendedMapView(Context context, String apiKey) {
super(context, apiKey);
}
public void setCurrentLocation (Location location)
{
currentLocation = location;
}
public Location getCurrentLocation ()
{
return currentLocation;
}
}
布局XML(map.xml):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.sit.augmented_reality.map.ExtendedMapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:id="@+id/map_view"
android:apiKey="0zGaDxZvhGnutaf58dLLydh5riLex42FsZ7UKcA" />
</RelativeLayout>