在Monodroid中扩展shadowbuilder有编译错误

时间:2012-11-10 15:12:05

标签: xamarin.android

我想扩展ShadowBuilder,以便在拖动时更改画布大小。但是,由于下面的编译错误,我无法编译它。

这是我的ShadowBuilder的代码

public class TileShadow : View.DragShadowBuilder
{
    //private Drawable mShadow;

    public TileShadow()
    {
    }

    public TileShadow(View view)
        : base(view)
    {
    }

    protected TileShadow(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
    {
    }

    public override void OnDrawShadow(Canvas canvas)
    {
        canvas.Scale(1.8f, 1.8f);
        base.OnDrawShadow(canvas);
        //mShadow.Draw(canvas);
        //View.Draw(canvas);
    }
}

错误25找不到符号 symbol:类DragShadowBuilder location:类android.view.View     扩展了android.view.View.DragShadowBuilder

enter image description here

1 个答案:

答案 0 :(得分:0)

您定位的API级别是多少? DragShadowBuilder在11级以后可用。

我在Mono for Android 4.2.6上针对API级别12(使用最低级别Android 3.1)测试了您的代码,并且编译没有问题并部署到模拟器。

您是否尝试过清洁/重建解决方案?

您是否尝试过从头开始创建新项目并实施此类,以查看问题是否与现有解决方案隔离?

还要检查你的ACW在obj \ debug \ android \ src \ wordshuffle \ android \ shadowbuilders \文件夹中的样子。

我看起来像这样

package androidapplication1;


public class TileShadow
    extends android.view.View.DragShadowBuilder
    implements
        mono.android.IGCUserPeer
    {
    static final String __md_methods;
    static {
        __md_methods = 
            "n_onDrawShadow:(Landroid/graphics/Canvas;)V:GetOnDrawShadow_Landroid_graphics_Canvas_Handler\n" +
            "";
        mono.android.Runtime.register ("AndroidApplication1.TileShadow, AndroidApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", TileShadow.class, __md_methods);
    }


    public TileShadow (android.view.View p0)
    {
        super (p0);
        if (getClass () == TileShadow.class)
            mono.android.TypeManager.Activate ("AndroidApplication1.TileShadow, AndroidApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Android.Views.View, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=c4c4237547e4b6cd", this, new java.lang.Object[] { p0 });
    }


    public TileShadow ()
    {
        super ();
        if (getClass () == TileShadow.class)
            mono.android.TypeManager.Activate ("AndroidApplication1.TileShadow, AndroidApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "", this, new java.lang.Object[] {  });
    }


    public void onDrawShadow (android.graphics.Canvas p0)
    {
        n_onDrawShadow (p0);
    }

    private native void n_onDrawShadow (android.graphics.Canvas p0);

    java.util.ArrayList refList;
    public void monodroidAddReference (java.lang.Object obj)
    {
        if (refList == null)
            refList = new java.util.ArrayList ();
        refList.add (obj);
    }

    public void monodroidClearReferences ()
    {
        if (refList != null)
            refList.clear ();
    }
}