2012-03-06 4 views
0

MapView에서 두 가지 메소드를 변경해야하므로 확장 한 클래스를 완료했습니다. 이 클래스를 사용하려고 할 때 응용 프로그램이 충돌하고 Log : Unable to start activity. 때문에 mapViewC mapView = (mapViewC) findViewById(R.id.mapview); 내 클래스의MapView 확장하기

GameMapActivity: java.lang.ClassCastException: com.google.android.maps.MapView cannot be cast to com.lemonbyte.games.lbg.mapViewC

는 mapViewC가지도보기 {

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); 
} 

}를 확장 공용 클래스가

내가 잘못 뭐하는 거지 이하? :) 고맙습니다!

+0

또한 layout.xml 파일을 표시하십시오. –

답변

3

레이아웃 xml에 MapView 요소의 이름을 com.lemonbyte.games.lbg.mapViewC으로 바꿉니다 (또한 클래스는 대문자로 시작하는 첫 번째 문자로 이름이 지정됩니다).

+0

감사합니다 Jami! :) – Misca