I'd like to ask a question
zondaOf2012 opened this issue · comments
With using ItemAnimators, whether we should use viewholder.getPosition in place of position on the onBindViewHolder()
?
Sorry, I didn't make it clear. I mean using notifyItemInserted()
or notifyItemRemoved
causedposition
error in the public void onBindViewHolder(RecyclerViewHolder holder, int position)
.
For example,
@Override
public void onBindViewHolder(RecyclerViewHolder holder, int position) {
holder.contentTv.setText(mDatas.get(position));
final int pos = position;
holder.contentTv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(mInflater.getContext(), "RecyclerAdapter onClick position: " + pos, Toast.LENGTH_SHORT).show();
}
});
}