2011-10-08 123 views
0

我正在實現自定義的mapview來覆蓋觸摸事件。這裏有雲代碼自定義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: ERROR/AndroidRuntime(5615): java.lang.NoSuchMethodException:CustomeMapView(上下文,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: ERROR/AndroidRuntime(5615):at android.view.LayoutInflater.createView(LayoutInflater.java:480)

注意:我已經設置了互聯網權限,粗略位置。幷包括使用庫標籤。 我在做什麼錯。

在此先感謝。

回答

相關問題