Closed aubryll closed 7 years ago
solved it, actually getAdapterPosition() returns the position inclusive of the headers, so what I did was I moved my clicklistener into the onBindItemViewHolder here is a snippet
holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onItemClickedListenerAdapter.onItemClicked(v, position); } });
and it worked, I urge everyone to avoid using getAdapterPosition() unless they are up for some serious drama
How do you implement a click listener on an adapter if am wrong? I implemented SectionedGridview, it works superb even the search funtionality except the clicklistener, here is how I made mine
holder.btn_option.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onItemClickedListener.onItemClicked(v, holder.getAdapterPosition()); } });
where the onItemClickedListener is basically an interface, I get wrong positions