类要么必须声明为抽象或? [英] Class must either be declared abstract or?

查看:202
本文介绍了类要么必须声明为抽象或?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的机器人。我一直使用的片段创建我的应用程序。
所以我复制材料风格抽屉从这里 >。

I am new to android. I have always used snippets to create my app. So I copied material style drawer from this here.

现在我面临的一个问题在code的这一部分:

Now I am facing a problem in this part of the code:

static class RecyclerTouchListener implements RecyclerView.OnItemTouchListener {

    private GestureDetector gestureDetector;
    private ClickListener clickListener;

    public RecyclerTouchListener(Context context, final RecyclerView recyclerView, final ClickListener clickListener) {
        this.clickListener = clickListener;
        gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
            @Override
            public boolean onSingleTapUp(MotionEvent e) {
                return true;
            }

            @Override
            public void onLongPress(MotionEvent e) {
                View child = recyclerView.findChildViewUnder(e.getX(), e.getY());
                if (child != null && clickListener != null) {
                    clickListener.onLongClick(child, recyclerView.getChildPosition(child));
                }
            }
        });
    }

    @Override
    public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {

        View child = rv.findChildViewUnder(e.getX(), e.getY());
        if (child != null && clickListener != null && gestureDetector.onTouchEvent(e)) {
            clickListener.onClick(child, rv.getChildPosition(child));
        }
        return false;
    }

    @Override
    public void onTouchEvent(RecyclerView rv, MotionEvent e) {
    }
}

在这个片段中提示错误。我可以给图片

In this snippet it gives error . I can give image of error

我试图使类抽象的,但随后与OnCreate中捆绑code干扰。任何帮助将是AP preciated

I tried to make the class abstract, but then it interferes with oncreate bundle code. Any help would be appreciated

推荐答案

此消息告诉您,那 RecyclerView.OnItemTouchListener (这是一个接口)定义了一个方法调用 onRequestDisallowInterceptTouchEvent(布尔)。此方法需要每天通过它们实现 OnItemTouchListener 接口的类实现。

This message tells you, that the RecyclerView.OnItemTouchListener (which is an interface) defines a method called onRequestDisallowInterceptTouchEvent(boolean). This method needs to be implemented by every class which implement the OnItemTouchListener interface.

所以只需添加此方法体为空...

So just add this method with an empty body...

@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}

...并且对Java语言界面一看:
https://docs.oracle.com/javase/tutorial/java/concepts /interface.html

这篇关于类要么必须声明为抽象或?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆