简体   繁体   English

如何禁用父子recyclerview(嵌套recyclerview)的点击/触摸事件但滚动需要工作

[英]How to disable the click/touch events for parent and child recyclerview(nested recyclerview) but scrolling needs to work

I have tried with this code.我已经尝试过使用此代码。

recyclerview.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
                @Override
                public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
                    return true;
                }
                @Override
                public void onTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {

                }
                @Override
                public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
                }
            });

Using this disabling the touch event is working fine.使用此禁用触摸事件工作正常。 But scrolling not working.但滚动不起作用。 Thanks in advance.提前致谢。

By default I believe the RecyclerView will not have any click/touch enabled, so you don't really need to do anything to get the behavior you want.默认情况下,我相信 RecyclerView 不会启用任何点击/触摸功能,因此您实际上不需要做任何事情来获得您想要的行为。 Adding a addOnItemTouchListener this way will definitely block the scrolling behavior if you don't fully implement the onTouchEvent which seems unnecessary in this case.如果您没有完全实现在这种情况下似乎没有必要的onTouchEvent ,那么以这种方式添加addOnItemTouchListener肯定会阻止滚动行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 嵌套的 RecyclerView。 如何防止父 RecyclerView 在子 RecyclerView 滚动时滚动? - Nested RecyclerView. How to prevent parent RecyclerView from getting scrolled while child RecyclerView is scrolling? 选择了RecyclerView项目以及如何禁用触摸事件 - RecyclerView item selected and how to disable Touch events 在子Recyclerview android中禁用滚动 - Disable Scrolling in child Recyclerview android 如何禁用 RecyclerView 滚动? - How to disable RecyclerView scrolling? 如何处理嵌套recyclerview中recyclerview子项中每个项目的点击事件 - how to handle click event for each item in recyclerview child in nested recyclerview 父级RecyclerView单击事件的子级RecyclerView项 - Items of Child RecyclerView of parent RecyclerView click event 如何在父级(ScrollView)完全滚动之前禁用子级(RecyclerView)滚动 - How to disable child(RecyclerView) scrolling before parent(ScrollView) has completely scrolled 禁用 RecyclerView 的触摸事件(以防止用户触摸)? - disable touch events of RecyclerView (to prevent user touches)? 在NestedScrollV中禁用RecyclerView的触摸事件 - disable touch events for RecyclerView inside NestedScrollV 单击子recyclerview后如何在嵌套recyclerview中获取父recyclerview值 - How to get parent recyclerview value in nested recyclerview after clicking child recyclerview
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM