0

コアラーとして機能する4つのポイントを考慮して、OSMのマップビューを制限しようとしています。

この質問に関連して、私はBoundedMapView.java(このWebサイトから入手)を使用してこれを支援しようとしています。

これは私のアクティビティコードです:

public class POfflineMapView extends Activity implements LocationListener, MapViewConstants{

    private BoundedMapView myOpenMapView;
    //... removed unreleated variables
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    mResourceProxy = new DefaultResourceProxyImpl(getApplicationContext());
    setContentView(R.layout.offline_map_activity);
    myOpenMapView = (BoundedMapView) findViewById(R.id.openmapview);
    myOpenMapView.getTileProvider().clearTileCache();

    //removed unlreleated codes

    BoundingBoxE6 bbox = new BoundingBoxE6(north,east,south,west);
    myOpenMapView.setScrollableAreaLimit(bbox);
    }
}   

これは私のxmlです:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

    <entity.BoundedMapView
        android:id="@+id/openmapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
</LinearLayout>

私のLogCatはこのエラーを示しています:

12-28 17:24:11.830: E/AndroidRuntime(14459): Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]

なぜまだこのエラーが発生するのかわかりません。BoundedMapViewはMapViewクラスから拡張されていますが、コンストラクターでエラーが発生するのはなぜですか?

私がこのエラーを正しく解釈していないように思われる場合は、親切に教えてください、ありがとう!

4

1 に答える 1

1

これはBoundedMapView、xmlコードで作成すると、次のコンストラクターが呼び出されないためです。

public BoundedMapView(final Context context, final AttributeSet attrs) {
    super(context, 256, new DefaultResourceProxyImpl(context), null, null, attrs);
}
于 2013-01-02T19:49:52.010 に答える