gabrielemariotti / RecyclerViewItemAnimators

An Android library which provides simple Item animations to RecyclerView items

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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();

            }
        });
    }