Search code examples
androidinterfacexamarindisposeontouchlistener

Implementing the View.IOnTouchListener interface


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


Solution

  • 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