自定义mapview无法正常工作?

时间:2011-10-08 03:10:41

标签: android google-maps nosuchmethoderror

我正在实现自定义mapview以覆盖触摸事件。这里是代码

public class CustomMapView extends com.google.android.maps.MapView {
public GlympseMapView(Context context, String apiKey) {
    super(context, apiKey);
    // TODO Auto-generated constructor stub
}

public static boolean LOG_DEBUG = true;
public static String TAG = GlympseMapView.class.getName();

@Override
public boolean onTouchEvent(MotionEvent ev) {
    // TODO Auto-generated method stub

    if (LOG_DEBUG) {
        Log.i(TAG, "on touch event :: map view called");
    }
    return super.onTouchEvent(ev);
}

}

这是布局定义:

  <com.packagename.mock.CustomMapView
    android:id="@+id/mapview"        
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:clickable="true"
    android:apiKey="0lq9O_Wyv7aby-na7rHhAR13GgzD5ItYdkiogVw"

我有一个扩展MapActivity的活动,我做了setcontent()。

  

但是在跑步的时候我得到10-07 20:08:46.918:   错误/ AndroidRuntime(5615):引起:   java.lang.NoSuchMethodException:CustomeMapView(Context,AttributeSet)   10-07 20:08:46.918:ERROR / AndroidRuntime(5615):at   java.lang.Class.getMatchingConstructor(Class.java:643)10-07   20:08:46.918:ERROR / AndroidRuntime(5615):at   java.lang.Class.getConstructor(Class.java:472)10-07 20:08:46.918:   错误/ AndroidRuntime(5615):at   android.view.LayoutInflater.createView(LayoutInflater.java:480)

注意:我已设置了互联网权限,粗略位置。并包含用户库标签。 我究竟做错了什么 。

提前致谢。

1 个答案:

答案 0 :(得分:1)

在您的代码类中,名称是CustomMapView,没有找到类名的构造函数。检查这个,

http://nocivus.posterous.com/double-clicktap-detection-on-a

http://pa.rezendi.com/2010/03/responding-to-zooms-and-pans-in.html

相关问题