我需要對MapView中的兩個方法進行一些更改,所以我做了一個擴展它的類。當我試圖使用這個類的應用程序崩潰,並與日誌:無法啓動活動。擴展MapView
GameMapActivity: java.lang.ClassCastException: com.google.android.maps.MapView cannot be cast to com.lemonbyte.games.lbg.mapViewC
因爲mapViewC mapView = (mapViewC) findViewById(R.id.mapview);
我班的低於 公共類mapViewC擴展的MapView {
public mapViewC(android.content.Context context, android.util.AttributeSet attrs){
super(context,attrs);
}
public mapViewC(Context context, String apiKey)
{
super(context, apiKey);
}
public mapViewC(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
}
@Override
public void dispatchDraw(Canvas canvas) {
//limit zoom level
if(getZoomLevel() >15){
getController().setZoom(15);
getController().setCenter(new GeoPoint(0, 0));
//dont draw as it will just be blank and then jump
return;
}
super.dispatchDraw(canvas);
}
}
我在做什麼錯? :) 謝謝!
也顯示您的layout.xml文件。 – 2012-03-06 13:13:18