我在我的 android 应用程序中显示谷歌地图。当用户双击地图时,我想放大。
我有 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.is.guide.ExtMapView
android:id="@+id/tourMapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="@string/apikey" />
和类如下
public class ExtMapView extends MapView {
private Context context;
private GestureDetector gestureDetector;
@SuppressWarnings("deprecation")
public ExtMapView(Context c, AttributeSet attrs) {
super(c, attrs);
context = c;
gestureDetector = new GestureDetector((OnGestureListener) context);
gestureDetector.setOnDoubleTapListener((OnDoubleTapListener) context);
}
public boolean onTouchEvent(MotionEvent ev) {
if (this.gestureDetector.onTouchEvent(ev))
return true;
else
return super.onTouchEvent(ev);
}
}
运行应用程序时出现 view.InflateException :(
我可能错过了什么?
异常如下
12-07 21:26:09.788: E/AndroidRuntime(6714): java.lang.RuntimeException:
Unable to start activity ComponentInfo{com.is.guide/com.is.TourMapActivity}:
android.view.InflateException: Binary XML file line #7: Error inflating class
com.is.guide.ExtMapView
12-07 21:26:09.788: E/AndroidRuntime(6714): Caused by: android.view.InflateException:
Binary XML file line #7: Error inflating class com.is.guide.ExtMapView
我提到了这个链接 http://dev.kafol.net/2011/11/how-hard-is-it-to-make-simple-zoom-in.html