Closed yanbin92 closed 7 years ago
,XRecyclerView 有header 下段代码中 int position = getPosition(viewHolder); position应该-1 protected void setListener(final ViewGroup parent, final RecyclerViewHolder viewHolder, int viewType) { if (!isEnabled(viewType)) return; viewHolder.getConvertView().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mOnItemClickListener != null) { int position = getPosition(viewHolder); mOnItemClickListener.onItemClick(parent, v, mDatas.get(position), position); } } });
viewHolder.getConvertView().setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (mOnItemClickListener != null) { int position = getPosition(viewHolder); return mOnItemClickListener.onItemLongClick(parent, v, mDatas.get(position), position); } return false; } }); }
,XRecyclerView 有header 下段代码中 int position = getPosition(viewHolder); position应该-1 protected void setListener(final ViewGroup parent, final RecyclerViewHolder viewHolder, int viewType) { if (!isEnabled(viewType)) return; viewHolder.getConvertView().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mOnItemClickListener != null) { int position = getPosition(viewHolder); mOnItemClickListener.onItemClick(parent, v, mDatas.get(position), position); } } });