1

我想扩展 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 找不到符号符号:类 DragShadowBuilder 位置:类 android.view.View 扩展 android.view.View.DragShadowBuilder

在此处输入图像描述

4

1 回答 1

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 ();
    }
}
于 2012-11-11T10:41:24.540 回答