9

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

Giru Bhai
  • 14,370
  • 5
  • 46
  • 74
Simon
  • 7,991
  • 21
  • 83
  • 163

1 Answers1

19

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

xakpc
  • 1,709
  • 13
  • 27