[英]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.