在 Visual Studio 中支持自定义 MapView/Android-View

Support for custom MapView/Android-View in Visual Studio

我正在使用 this walkthrough 中的原始 Java 版本将代码从 Java 翻译成 C#,我注意到在翻译时有一个主要问题,那就是自定义 MapView:

public MapView(Context context, int viewWidth, int viewHeight, DataClass tilesProvider, Bitmap positionmarker)
        {
            //super(context);

            //base.Context(context);
            //base is the equivalent to the unexplained use of super

            this.context = context;

            this.tileProvider = tilesProvider;

            this.viewHeight = viewHeight;
            this.viewWidth = viewWidth;

            this.positionmarker = positionmarker;

            tileManager = new TilesManager(256, viewWidth, viewHeight);

            initPaint();

            fetchTiles();



        }

我收到错误:"Android.Views.View does not contain a constructor that takes 0 arguments."

如果我将其设为静态 this 将不起作用,并且 View 基类中没有 MapView。

我怎样才能让它工作或者那是不可能的? 如果不可能,是否有可选的方法来做到这一点?

虽然我无法构建并且可能会在以后产生问题,但这是我找到的解决方案:

public MapView(Context context, int viewWidth, int viewHeight, DataClass tilesProvider, Bitmap positionMarker): base(context)
    {
        //base(context);
        //super(context);


        //base.Context(context);
        //base unexplained use of super that 

        this.context = context;

        this.tileProvider = tilesProvider;

        this.viewHeight = viewHeight;
        this.viewWidth = viewWidth;

        this.positionmarker = positionMarker;

        tileManager = new TilesManager(256, viewWidth, viewHeight);

        initPaint();

        fetchTiles();


        //return base.(context, viewWidth, viewHeight, tilesProvider, tilesManager);

    }

解决方案是将 : base(context) 放在方法声明中,而不是在 Java 版本中完成的方法中。我在 msdn.

上找到了解释

希望以后能用得上,希望对其他人有用! /E.A.O.S