【问题标题】:custom mapview not working?自定义地图视图不起作用?
【发布时间】:2011-10-08 03:10:41
【问题描述】:

我正在实现自定义地图视图以覆盖触摸事件。代码来了

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(上下文,属性集) 10-07 20:08:46.918: 错误/AndroidRuntime(5615): 在 java.lang.Class.getMatchingConstructor(Class.java:643) 10-07 20:08:46.918:错误/AndroidRuntime(5615):在 java.lang.Class.getConstructor(Class.java:472) 10-07 20:08:46.918: 错误/AndroidRuntime(5615):在 android.view.LayoutInflater.createView(LayoutInflater.java:480)

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

提前致谢。

【问题讨论】:

    标签: android google-maps nosuchmethoderror


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-21
      • 1970-01-01
      • 1970-01-01
      • 2020-10-12
      • 2014-04-26
      • 2020-01-18
      相关资源
      最近更新 更多