CymChad / BaseRecyclerViewAdapterHelper

BRVAH:Powerful and flexible RecyclerAdapter
http://www.recyclerview.org/
MIT License
24.33k stars 5.16k forks source link

使用 SectionAdapter 完成二级菜单时,childitem 点击事件无法监听到 #1287

Closed LayneCui closed 7 years ago

LayneCui commented 7 years ago

List bean = baseBean.getData(); mRecyclerView.setLayoutManager(new GridLayoutManager(context,4)); datas = dataProcess(bean); BusinessListAdapter sectionAdapter = new BusinessListAdapter(R.layout.item_x2_topic, R.layout.item_bussines_paarent_section,datas); mRecyclerView.setAdapter(sectionAdapter);

                    sectionAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
                        @Override
                        public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                            ToastUtils.showShort("1111");
                        }
                    });

                    sectionAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
                        @Override
                        public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                            ToastUtils.showShort("222");
                        }
                    });
CymChad commented 7 years ago

你在adapter里面绑定了child的id吗?

LayneCui commented 7 years ago

好像没有,我照着 demo 写的,我没见到 demo 里绑定 id 的代码呢

public BusinessListAdapter(int layoutResId, int sectionHeadResId, List data) { super(layoutResId, sectionHeadResId, data); }

@Override
protected void convertHead(BaseViewHolder helper, BusinessListSection item) {
    helper.setText(R.id.head,item.header);

}

@Override
protected void convert(BaseViewHolder helper, BusinessListSection item) {
    BusinessListBean.CBusinessCodeVosBean bean = item.t;
    helper.setText(R.id.cbx_item_topic,bean.getBusName());
}
CymChad commented 7 years ago

请查看文档 http://www.jianshu.com/p/b343fcff51b0 你看的adapter没有绑定,查相关ItemClickAdapter则有。

LayneCui commented 7 years ago

好的,谢谢大哥