Skip to content

Recyclerview 嵌套时, item点击事件处理,子Recyclerview不响应父Recyclerview的点击 #2516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
18810867174 opened this issue Oct 29, 2018 · 7 comments

Comments

@18810867174
Copy link

  helper.addOnClickListener(R.id.recycler_view);// adapter 里面设置子Recyclerview为子控件点击
 helper.addOnClickListener(R.id.btn2);

//Activity里面的监听
orderListAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
@OverRide
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
switch (view.getId()){
case R.id.recycler_view://不走
Log.e("--11111111111--->>",position+"");
break;
case R.id.btn2://走
Log.e("--22222222222--->>",position+"");
break;
}
}

@AllenCoder
Copy link
Collaborator

@cdcdec
Copy link

cdcdec commented Jul 26, 2019

我也遇到这个问题 ,我认为这个demo里面的写法 解决不了这个问题

@olyvcn
Copy link

olyvcn commented Apr 10, 2020

@18810867174 你好,问题解决了吗

@18810867174
Copy link
Author

18810867174 commented Apr 10, 2020 via email

@olyvcn
Copy link

olyvcn commented Apr 10, 2020

@18810867174 谢谢,期待你的好消息

@18810867174
Copy link
Author

18810867174 commented Apr 11, 2020 via email

@olyvcn
Copy link

olyvcn commented Apr 12, 2020

@18810867174

我遇到的情况是这样的,内部的RecyclerView是一个图片的列表,网格布局的,一行7个。

然后内部RecyclerView的每个item有个点击事件,查看大图的。

当我为外层的RecyclerView设置item的点击事件后,内部RecyclerView空白的地方,无法响应点击。

针对这个问题,我最后是这么处理的。

childAdapter.setOnItemClickListener((adapter, view, position) -> {
	// 查看大图
}
});

// 将子RecyclerView的点击事件传给外层itemView进行处理
childRV.setOnTouchListener((v, event) -> itemView.onTouchEvent(event));

🙏 最后感谢你的回复 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants