Implementing the View.IOnTouchListener interface

心已入冬 提交于 2019-12-08 17:30:32

问题


In Xamarin, I have coded a class that implements the View.IOnTouchListener interface.

Here is my code:

public class OnTouchListener : View.IOnTouchListener
{
    public bool OnTouch (View v, MotionEvent e)
    {
        return true;
    }

    void IDisposable.Dispose ()
    {
        throw new NotImplementedException ();
    }

    IntPtr Android.Runtime.IJavaObject.Handle {
        get {
            throw new NotImplementedException ();
        }
    }
}

What values do I need for the IDisposable.Dispose and Android.Runtime.IJavaObject.Handle code items, rather than the throw new NotImplementedException () code?

Thanks in advance


回答1:


You should inherit Java.Lang.Object in your OnTouchListener like this

public class OnTouchListener : Java.Lang.Object,  View.IOnTouchListener

it will implement Handle and Dispose

you should do this whenever implement any Java interface



来源:https://stackoverflow.com/questions/24502974/implementing-the-view-iontouchlistener-interface

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!