android - 实现 View.IOnTouchListener 接口(interface)

标签 android interface xamarin dispose ontouchlistener

在 Xamarin 中,我编写了一个实现 View.IOnTouchListener 接口(interface)的类。

这是我的代码:

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 ();
        }
    }
}

IDisposable.DisposeAndroid.Runtime.IJavaObject.Handle 代码项需要什么值,而不是 throw new NotImplementedException ()代码?

提前致谢

最佳答案

你应该像这样在你的 OnTouchListener 中继承 Java.Lang.Object

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

它将实现 Handle 和 Dispose

每当实现任何 Java 接口(interface)时都应该这样做

关于android - 实现 View.IOnTouchListener 接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24502974/

相关文章:

android - 如何在 React Native 中创建对角线边框?

java - RecyclerView适配器类中Android View Binding的正确方式是什么?

java - Eclipse 希望实现不存在的方法

c# - 如何在 WCF 中使用接口(interface)作为数据契约

c# - Google APIs vs Google Play vs Intel x86 vs Android TV vs Wear OS Intel x86 系统图像差异

c# - 如何创建一个在后台运行的计时器而不用 Xamarin 阻塞 UI 线程?

android - fragment 中不合适的上下文菜单

java - 无法引用主 android 库

c - 如何使用 Fortran 接口(interface)调用包含用户定义类型的 C 函数

java - Xamarin.Android 绑定(bind)调用 java 对象方法