我创建了一个RecyclerView包含垂直方向的项目列表
我在父级RecyclerView的单个节点中添加了另一个RecyclerView,以显示每个单元格内的项目网格
我在单元格中为网格项添加了一个点击监听器,如:mRvHomeMosaic.setOnClickListener(this);
在视图持有者中,但它没有被点击触发。
如果有人有同样的问题,请帮助我。或任何使用嵌套RecyclerView的人。
我的Holder类和onBindView()在下面给出
class HomeViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
RecyclerView mRvHomeMosaic;
public HomeViewHolder(View itemView) {
super(itemView);
this.mRvHomeMosaic = (RecyclerView) itemView.findViewById(R.id.rv_home_mosaic_image);
mRvHomeMosaic.setEnabled(true);
mRvHomeMosaic.setOnClickListener(this);
}
@Override
public void onClick(View view) {
if (clickListener != null) {
clickListener.itemClickListner(view, getPosition());
}
}
}
@Override
public void onBindViewHolder(final HomeViewHolder holder, int position) {
if (mDataList.get(position).getmMosaicModelList() != null &&
mDataList.get(position).getmMosaicModelList().size() > 0) {
holder.mRvHomeMosaic.setEnabled(true);
HomeSubAdapter adapter = new HomeSubAdapter(mContext, mDataList.get(position).
getmMosaicModelList());
holder.mRvHomeMosaic.setAdapter(adapter);
StaggeredGridLayoutManager mLayoutManager = new StaggeredGridLayoutManager(3,
StaggeredGridLayoutManager.VERTICAL);
holder.mRvHomeMosaic.setLayoutManager(mLayoutManager);
} else {
holder.mRvHomeMosaic.setEnabled(true);
List<MosaicTileModel> modelList = new ArrayList<>();
MosaicTileAdapter adapter = new MosaicTileAdapter(mContext, modelList);
holder.mRvHomeMosaic.setAdapter(adapter);
StaggeredGridLayoutManager mLayoutManager = new StaggeredGridLayoutManager(3,
StaggeredGridLayoutManager.VERTICAL);
holder.mRvHomeMosaic.setLayoutManager(mLayoutManager);
}
}`
单个节点也有一些其他项目。单击侦听器正确触发了该项。但在内部Recylcerview对象的情况下,它没有被触发。