我需要对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